2
有沒有辦法做到這一點?就像在屏幕的任何部分點擊都會消除部分模態捲曲。 我曾想過一個看不見的按鈕,但仍然沒有覆蓋整個捲曲區域。iOS - 增加部分捲曲水龍頭區域以關閉模式
有沒有辦法做到這一點?就像在屏幕的任何部分點擊都會消除部分模態捲曲。 我曾想過一個看不見的按鈕,但仍然沒有覆蓋整個捲曲區域。iOS - 增加部分捲曲水龍頭區域以關閉模式
添加手勢識別你的主視圖viewDidLoad
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(getDismissed)];
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(getDismissed)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.numberOfTouchesRequired = 1;
tapRecognizer.delegate = self;
[self.view addGestureRecognizer:tapRecognizer];
[self.view addGestureRecognizer:swipeRecognizer];
-(void)getDismissed
{
// call dismissViewControllerAnimated:completion: by the presenting view controller
// you can use delegation or direct call using presentingViewController property
}
然後在視圖,你不想觸發解僱
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
// touching objects of type UIControl will not dismiss the view controller
return ![touch.view isKindOfClass:[UIControl class]];
}
謝謝排除。我很久以前需要這個。但我期待下一次使用。 ;) – Milad 2012-10-07 06:48:32