iOS 摇一摇的实现-备用
2016-02-24 23:37
459 查看
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
[self becomeFirstResponder];
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//检测到摇动
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//摇动结束
if (event.subtype == UIEventSubtypeMotionShake) {
//something happens
[self test];
}
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//摇动取消
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
-(void)test
{
NSLog(@"完成摇动后处理事件");
}
{
[super viewDidLoad];
[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
[self becomeFirstResponder];
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//检测到摇动
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//摇动结束
if (event.subtype == UIEventSubtypeMotionShake) {
//something happens
[self test];
}
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//摇动取消
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
-(void)test
{
NSLog(@"完成摇动后处理事件");
}
相关文章推荐
- iOS绘图教程
- iOS 第三方库 - Masonry
- iOS 第三方库 - MJRefresh
- iOS 第三方库 - MJExtension
- iOS 第三方库 - FastCoding
- iOS NSDictionary、NSData、JSON等 数据类型相互转换
- 常用第三方库与框架
- iOS 第三方库 - MBProgressHUD
- iOS开发CocoaPods使用
- IOS 布局
- iOS多线程
- IOS基础之 (十一) 内存管理 ARC
- iOS中容易造成循环引用的三种场景
- 解决CCEditBox 在iOS9下导致场景偏移的问题
- iOS arc和mrc下重写set方法
- iOS NSTimer定时器详解
- IOS中的数据存储 简单总结
- iOS 开发中用户记住账户,密码
- Missing iOS Distribution signing identity for ...
- iOS 创建单例的两种方法