大佬教程收集整理的这篇文章主要介绍了Iphone SDK通过点击它外面的ipad上关闭Modal ViewControllers,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@SELEctor(handleTapBehind:)]; [recognizer setnumberOfTapsrequired:1]; recognizer.cancelsTouchesInView = NO; //So the user can still interact with controls in the modal view [self.view.window addGestureRecognizer:recognizer]; [recognizer release];
处理代码:
- (void)handleTapBehind:(UITapGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { CGPoint LOCATIOn = [sender LOCATIOnInView:nil]; //Passing nil gives us coordinates in the window //Then we convert the tap's LOCATIOn into the local view's coordinate system,and test to see if it's in or outside. If outside,dismiss the view. if (![self.view poinTinside:[self.view convertPoint:LOCATIOn fromView:self.view.window] withEvent:nil]) { // Remove the recognizer first so it's view.window is valid. [self.view.window removeGestureRecognizer:sender]; [self dismissModalViewControllerAnimated:YES]; } } }
就是这样。 HIG被诅,,这是一个有用的和经常直观的行为。
以上是大佬教程为你收集整理的Iphone SDK通过点击它外面的ipad上关闭Modal ViewControllers全部内容,希望文章能够帮你解决Iphone SDK通过点击它外面的ipad上关闭Modal ViewControllers所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。