让你的模态视图控制器附加一个手势识别器到视图的窗口:
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];@H_@R_419_6941@_18@处理代码:
- (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]; } }}@H_@R_419_6941@_18@就是这样。 HIG被诅,,这是一个有用的和经常直观的行为。
总结以上是内存溢出为你收集整理的Iphone SDK通过点击它外面的ipad上关闭Modal ViewControllers全部内容,希望文章能够帮你解决Iphone SDK通过点击它外面的ipad上关闭Modal ViewControllers所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)