如何使用 ObjectC 向下拖动以关闭模式
Posted
技术标签:
【中文标题】如何使用 ObjectC 向下拖动以关闭模式【英文标题】:How to drag down to dismiss a modal with ObjectC 【发布时间】:2018-04-09 12:56:17 【问题描述】:我想通过像 twitter 应用程序的照片视图那样下拉照片来关闭模态视图。
我找到了same issue,但它是用 Swift 编写的。
我需要 Object-C 版本。
【问题讨论】:
【参考方案1】:您可以使用 UISwipeGestureRecognizer (Down) 来实现该行为。
使用以下代码向模型视图添加手势:
UISwipeGestureRecognizer *downGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(downGestureHandler:)];
[gestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
[self.view addGestureRecognizer: downGestureRecognizer];
关闭模型视图的方法:
-(void) downGestureHandler:(UISwipeGestureRecognizer *)recognizer
//Code to dismiss model view with animation
【讨论】:
以上是关于如何使用 ObjectC 向下拖动以关闭模式的主要内容,如果未能解决你的问题,请参考以下文章
C# DataGridView 数据显示到最后一行后,如何使滚动条继续向下滚动。
如何使用 @angular/cdk 使 NgbModal 可拖动