zoukankan      html  css  js  c++  java
  • IOS 摇一摇的方法

    监控摇一摇的方法
    方法1:通过分析加速计数据来判断是否进行了摇一摇操作(比较复杂)
    方法2:iOS自带的Shake监控API(非常简单)

    判断摇一摇的步骤:实现3个摇一摇监听方法
    - (void)motionBegan:(UIEventSubtype)motion withEvent:

    (UIEvent *)event /** 检测到摇动 */


    - (void)motionCancelled:(UIEventSubtype)motion

    withEvent:(UIEvent *)event /** 摇动取消(被中断) */


    - (void)motionEnded:(UIEventSubtype)motion withEvent:

    (UIEvent *)event /** 摇动结束 */

    #import "HMViewController.h"
    #import <sys/socket.h>
    
    @interface HMViewController ()
    
    @end
    
    @implementation HMViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        Class c = NSClassFromString(@"UINavigationTransitionView");
        
        UIView *view =  [[c alloc] init];
        
        NSLog(@"%@", view);
    //    UINavigationController *nav = [[UINavigationController alloc] init];
    //    NSLog(@"%@", nav.view.subviews);
    }
    
    #pragma mark - 实现相应的响应者方法
    /** 开始摇一摇 */
    - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
        NSLog(@"motionBegan");
    }
    
    /** 摇一摇结束(需要在这里处理结束后的代码) */
    - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
        // 不是摇一摇运动事件
        if (motion != UIEventSubtypeMotionShake) return;
        
        NSLog(@"motionEnded");
    }
    
    /** 摇一摇取消(被中断,比如突然来电) */
    - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
        NSLog(@"motionCancelled");
    }
    @end
  • 相关阅读:
    如遇临时表无法删除
    ORA-00054:resource busy and acquire with nowait specified解决方法
    查看用户建立详细原语句
    dbtool部署
    启动uiautomatorview 提示无法初始化主类
    运行虚拟机报错:CPU acceleration status: HAXM is not installed on this machine
    Appium-Python-Windows 环境搭建
    Vagrant安装Docker
    XPath
    Selenium之元素定位
  • 原文地址:https://www.cnblogs.com/liuwj/p/6870037.html
Copyright © 2011-2022 走看看