Ste*_*ven 11 iphone uinavigationcontroller uigesturerecognizer ios ios7
在新的iOS 7中UINavigationController,有一个滑动手势可在视图之间切换.有没有办法检测或拦截手势?
Aus*_*tin 31
交互式流行手势识别是通过暴露UINavigationController的interactivePopGestureRecognizer财产.您可以添加自己的控制器作为手势识别器的目标并进行适当的响应:
@implementation MyViewController
...
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController.interactivePopGestureRecognizer addTarget:self
action:@selector(handlePopGesture:)];
}
- (void)handlePopGesture:(UIGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateBegan)
{
// respond to beginning of pop gesture
}
// handle other gesture states, if desired
}
...
@end
Run Code Online (Sandbox Code Playgroud)
小智 12
这是奥斯汀在斯威夫特的回答.使用这篇文章构建选择器,我发现以下工作.
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.interactivePopGestureRecognizer?.addTarget(self, action:#selector(self.handlePopGesture))
}
func handlePopGesture(gesture: UIGestureRecognizer) -> Void {
if gesture.state == UIGestureRecognizerState.Began {
// respond to beginning of pop gesture
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7265 次 |
| 最近记录: |