【问题标题】:Shake Gesture To Random Table View Cell [duplicate]摇动手势到随机表视图单元格[重复]
【发布时间】:2013-06-29 18:01:49
【问题描述】:

我目前正在对我的应用程序进行更新 3,我想添加摇动 iPhone 并让它进入我的 UITableView 中的随机单元格的功能。我知道 Apple 建议不要做这种手势,但我想添加它或至少尝试一下。

任何帮助将不胜感激!

【问题讨论】:

    标签: ios uitableview


    【解决方案1】:

    使用这个

    -(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
           if(motion == UIEventSubtypeMotionShake)
           {
              NSLog(@"Shake");
           }
    }
    -(BOOL)canBecomeFirstResponder
    {
        return YES;
    }
    

    【讨论】:

    • 需要通过调用-becomeFirstResponder方法将view/controller设置为firstResponder,同时实现canBecomeFirstResponder方法并返回YES来响应shake事件。
    • 是的。感谢@amar 添加此内容。
    猜你喜欢
    • 2012-03-11
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2019-02-14
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多