摇一摇功能实现

#pragma mark yaoyiyao  
- (BOOL)canBecomeFirstResponder  
{  
    return YES;// default is NO  
}  
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event  
{  
    NSLog(@"开始摇动手机");  
}  
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event  
{  
    NSLog(@"stop");  
    UIAlertView *yaoyiyao = [[UIAlertView alloc]initWithTitle:@"温馨提示:" message:@"您摇动了手机,想干嘛?" delegate:self cancelButtonTitle:@"CANCEL" otherButtonTitles: nil nil];  
    [yaoyiyao show];  
}  
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event  
{  
    NSLog(@"取消");  
}  

转自http://blog.csdn.net/hu_songsong/article/details/12981505

 
原文地址:https://www.cnblogs.com/huoxingdeguoguo/p/4717150.html