【发布时间】:2013-06-29 18:01:49
【问题描述】:
我目前正在对我的应用程序进行更新 3,我想添加摇动 iPhone 并让它进入我的 UITableView 中的随机单元格的功能。我知道 Apple 建议不要做这种手势,但我想添加它或至少尝试一下。
任何帮助将不胜感激!
【问题讨论】:
标签: ios uitableview
我目前正在对我的应用程序进行更新 3,我想添加摇动 iPhone 并让它进入我的 UITableView 中的随机单元格的功能。我知道 Apple 建议不要做这种手势,但我想添加它或至少尝试一下。
任何帮助将不胜感激!
【问题讨论】:
标签: ios uitableview
使用这个
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if(motion == UIEventSubtypeMotionShake)
{
NSLog(@"Shake");
}
}
-(BOOL)canBecomeFirstResponder
{
return YES;
}
【讨论】:
-becomeFirstResponder方法将view/controller设置为firstResponder,同时实现canBecomeFirstResponder方法并返回YES来响应shake事件。