zoukankan      html  css  js  c++  java
  • app 摇一摇功能

    1.重写canBecomeFirstResponder ,并返回YES

    -(BOOL)canBecomeFirstResponder{
        return YES;
    }

    2.重写UIResponder的三个方法

    -(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
        NSLog(@"在摇了");
    }
    
    -(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
        
        if (event.subtype == UIEventSubtypeMotionShake) {
            NSLog(@"stop");
            
            int i = arc4random_uniform(12);
            NSLog(@"%d",i);
            NSString *str = nil;
            if (i == 3) {
                str = @"你运气真好,中奖了";
            }else{
                str = @"你还有3次机会";
            }
            
            UIAlertView *yaoyao = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:str delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
            [yaoyao show];
        }
        
    }
    
    -(void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event{
        NSLog(@"取消");
    }
  • 相关阅读:
    exchangeNetwork
    VRP OS Management
    filleSystemBasises
    Study_way
    1.MySQL 安装
    7.进程池与线程池
    6.线程
    5.进程 -锁
    4.进程-1
    3.多线程TCP协议与加密方式
  • 原文地址:https://www.cnblogs.com/gulong/p/4716116.html
Copyright © 2011-2022 走看看