2012-07-06 1 views
2

방법이 있습니까? 화면의 어떤 부분을 두드리는 것과 같이 부분 모달 컬을 닫습니다. 보이지 않는 버튼에 대해 생각했지만 여전히 전체 컬 영역을 다루지는 않습니다. viewDidLoadiOS - 부분 컬 탭 영역을 늘려서 모달을 닫습니다.

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 
} 

에 기본보기에

답변

1

추가 제스처 인식기는 그런 다음

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch 
{ 
    // touching objects of type UIControl will not dismiss the view controller 
    return ![touch.view isKindOfClass:[UIControl class]]; 
} 
+0

가 감사 해임을 트리거하지 않으려는보기에서 제외합니다. 나는 이것을 오래 전에 필요로했다. 그러나 나는 다음 사용을 고대하고있다. ;) – Milad