[英]How to drag down to dismiss a modal with ObjectC
I want to dismiss a modal view with dragging down photo like twitter app's photo views. 我想通过拖拽照片(如Twitter应用程序的照片视图)来消除模式视图。
I found same issue , but it written in Swift. 我发现了同样的问题 ,但是它是用Swift编写的。
I need Object-C version. 我需要Object-C版本。
You can use UISwipeGestureRecognizer (Down) to achieve the behaviour. 您可以使用UISwipeGestureRecognizer(向下)来实现该行为。
Add gesture to the model view using below code: 使用以下代码向模型视图添加手势:
UISwipeGestureRecognizer *downGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(downGestureHandler:)];
[gestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
[self.view addGestureRecognizer: downGestureRecognizer];
The method to dismiss the model view: 消除模型视图的方法:
-(void) downGestureHandler:(UISwipeGestureRecognizer *)recognizer {
//Code to dismiss model view with animation
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.