zoukankan      html  css  js  c++  java
  • CMDeviceMotion使用

    CMDeviceMotion使用

    by 吴雪莹

    manager = [[CMMotionManager alloc] init];
    ViewController *__weak weakSelf=self;
    // 1
    if(manager.deviceMotionAvailable){
        manager.deviceMotionUpdateInterval=0.01f;
        [manager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue]
             withHandler:^(CMDeviceMotion*data,NSError*error){
                 double rotation=atan2(data.gravity.x,data.gravity.y)-M_PI;
                 weakSelf.imageView.transform=CGAffineTransformMakeRotation(rotation);
                 }];
    }
    // 2
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];[manager startDeviceMotionUpdatesToQueue:queue
       withHandler:^(CMDeviceMotion *data, NSError *error) {
           
           [[NSOperationQueue mainQueue] addOperationWithBlock:^{
               double rotation=atan2(data.gravity.x,data.gravity.y)-M_PI;
               weakSelf.imageView.transform=CGAffineTransformMakeRotation(rotation);
           }];
       }];


    版权声明:本文博客原创文章。博客,未经同意,不得转载。

  • 相关阅读:
    kafka-->storm-->mongodb
    zuul filter
    使用Spring Cloud Feign
    kafka客户端发布record(消息)
    kafka java api消费者
    kafka java api生产者
    kafka安装和使用
    多线程分析
    springboot入门
    centos7上svn安装
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/4725254.html
Copyright © 2011-2022 走看看