Iphone SDK通过点击它外面的ipad上关闭Modal ViewControllers

Iphone SDK通过点击它外面的ipad上关闭Modal ViewControllers,第1张

概述我想关闭一个FormSheetPresentation模式视图控制器,当用户轻按模态视图…我已经看到一堆应用程序这样做(例如在ipad的ebay),但我不知道如何,因为下面的视图被禁用触摸当模态视图显示为这样(他们将它作为一个popover也许?)…任何人有任何建议? 我晚了一年,但这是相当直接。 让你的模态视图控制器附加一个手势识别器到视图的窗口: UITapGestureRecognizer 我想关闭一个FormSheetPresentation模式视图控制器,当用户轻按模态视图…我已经看到一堆应用程序这样做(例如在ipad的ebay),但我不知道如何,因为下面的视图被禁用触摸当模态视图显示为这样(他们将它作为一个popover也许?)…任何人有任何建议?解决方法 我晚了一年,但这是相当直接。

让你的模态视图控制器附加一个手势识别器到视图的窗口:

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所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1087935.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存