ios 摇一摇功能的实现
来源:互联网 发布:淘宝原价与折扣价设置 编辑:程序博客网 时间:2024/05/16 11:54
当我们用微信的时候是不是感觉摇一摇的功能很炫呢?是不是感觉实现起来比较麻烦呢?
其实,不然,这些都是苹果已经给我们封装好了,给我提供了非常简单的入口了。
在UIResponder中有这些方法:
- -(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
- NSLog(@"began");
- }
- -(void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event{
- NSLog(@"cancel");
- }
- -(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
- NSLog(@"end");
- }
在UIViewController的子类中都可以直接使用这些方法,因为UIViewController也是继承于UIResponder的。
实现中,需要让viewController这个类本身支持摇一摇这个功能。
代码:
- [[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
- [self becomeFirstResponder];
- <p class="p1">-(<span class="s1">BOOL</span>)canBecomeFirstResponder {</p><p class="p2"><span class="s2"> </span>return<span class="s2"> </span>YES<span class="s2">;</span></p><p class="p1">}</p>
0 0
- ios 摇一摇功能的实现
- ios 摇一摇功能的实现
- iOS摇一摇功能的实现
- iOS 摇一摇功能的实现
- iOS 摇一摇功能的实现
- IOS摇一摇功能实现
- iOS摇一摇功能实现
- iOS 实现摇一摇功能
- ios-摇一摇功能实现
- iOS开发之摇一摇功能的实现
- iOS开发之摇一摇功能的实现
- iOS开发之摇一摇功能的实现
- iOS开发之摇一摇功能的实现
- iOS开发之摇一摇功能的实现
- iOS巅峰之摇一摇功能的实现
- ios录音功能的实现
- iOS 录音功能的实现
- IOS推送功能的实现
- 第7周作业2-极值计算
- java jdk1.6内置支持的webservice使用示例
- MFC LNK2019: 无法解析的外部符号
- 日本3D打印骨骼技术正等待政府批准上市
- Versions SVN Edit Repository BookMark 之后,本地Working Copy 的update无效
- ios 摇一摇功能的实现
- Spring MVC默认组件实现类
- JAVA中JDialog的举例
- 编译WINCE应用出现:Cannot open include file: 'ceconfig.h': No such file or directory
- Fastreport .NET 只显示一条记录
- schema中声明元素的几种方法
- android置安装图标和文字的地方
- IOS端的摇一摇功能
- android截屏