如何关闭全屏UIImageView?

时间:2018-08-29 12:41:18

标签: objective-c uiimageview

当我在应用程序中单击按钮时,我正在创建一个UIImageView

'posts_per_page' => -1

但是当我点击相同的视图时,如何关闭呢?

1 个答案:

答案 0 :(得分:0)

您可以在UITapGestureRecognizer中添加UIImageView,然后将其UIImageView移除。

//Add tap Gesture
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissTapGesture:)];
[dot addGestureRecognizer:tapGesture];
//Set userInteractionEnabled property of imageView to true because by defaults its false
dot.userInteractionEnabled = YES;

现在只需通过UIImageView的操作方法删除UITapGestureRecognizer

- (void)dismissTapGesture:(UITapGestureRecognizer*)gesture {
    [gesture.view removeFromSuperview];
}