您的位置:首页 > 移动开发 > 微信开发

iOS开发关于微信摇一摇功能的简单的介绍

2015-12-22 18:02 666 查看
控制器中.m的实现

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
//微信的摇一摇是怎么实现的~发现原来 ios本身就支持
//在 UIResponder中存在这么一套方法,只需要在相关方法中做处理即可

[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];

[self becomeFirstResponder];// 让控制器成为第一响应者,支持摇动
}

/**
* 开始摇晃就会调用
*/
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"%s", __func__);
}
/**
* 摇晃结束就会调用
*/
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"%s", __func__);
}
/**
* 摇晃被打断就会调用
*/
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"%s", __func__);
}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息