簡體   English   中英

如何使用ObjectC向下拖動以消除模態

[英]How to drag down to dismiss a modal with ObjectC

我想通過拖拽照片(如Twitter應用程序的照片視圖)來消除模式視圖。

我發現了同樣的問題 ,但是它是用Swift編寫的。

我需要Object-C版本。

在此處輸入圖片說明

您可以使用UISwipeGestureRecognizer(向下)來實現該行為。

使用以下代碼向模型視圖添加手勢:

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
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM