【问题标题】:How to drag down to dismiss a modal with ObjectC如何使用 ObjectC 向下拖动以关闭模式
【发布时间】:2018-04-09 12:56:17
【问题描述】:

我想通过像 twitter 应用程序的照片视图那样下拉照片来关闭模态视图。

我找到了same issue,但它是用 Swift 编写的。

我需要 Object-C 版本。

【问题讨论】:

    标签: ios objective-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
    }
    

    【讨论】:

      猜你喜欢
      • 2015-05-31
      • 2020-07-06
      • 1970-01-01
      • 2019-11-12
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      • 1970-01-01
      • 2020-06-11
      相关资源
      最近更新 更多