objective-c – 在外部抽头上关闭模态视图表单控制器
发布时间:2020-12-15 02:03:59 所属栏目:百科 来源:网络整理
导读:当作为条形按钮项目的取消按钮被点击时,我将一个模态视图控制器呈现为表格表,并将其解除。当我点击该视图外面时,我需要解除它。请帮助我参考。注意:我的模态视图控制器带有导航控制器。 @cli_hlt,@Bill Brasky感谢您的回答。当点击发生在形式表格的模态
当作为条形按钮项目的取消按钮被点击时,我将一个模态视图控制器呈现为表格表,并将其解除。当我点击该视图外面时,我需要解除它。请帮助我参考。注意:我的模态视图控制器带有导航控制器。
@cli_hlt,@Bill Brasky感谢您的回答。当点击发生在形式表格的模态视图之外时,我需要解除它。我正在粘贴我的代码。 -(void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index { if(adminMode) { CHEditEmployeeViewController *editVC = [[CHEditEmployeeViewController alloc] initWithNibName:@"CHEditEmployeeViewController" bundle:nil]; editVC.delegate = self; editVC.pickedEmployee = employee; editVC.edit = TRUE; editVC.delegate = self; UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:editVC]; navigationController.modalPresentationStyle = UIModalPresentationFormSheet; [self presentModalViewController:navigationController animated:YES]; return; } //the above code is from the view controller which presents the modal view. Please look at the below code too which is from my modal view controller. Please guide me in a proper way. -(void)tapGestureRecognizer { 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 addGestureRecognizer:recognizer]; } - (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]) { [self dismissModalViewControllerAnimated:YES]; [self.view.window removeGestureRecognizer:sender]; } } } 解决方法
喔好吧。所以恐怕这不是很可能使用presentModalViewController:方法。 “模态”视图/窗口/消息框/等的整个想法。 pp。是用户不能做任何其他处理任何视图/窗口/消息框/ etc。 pp。希望他/她做。
你想要做的是不是一个模态视图控制器,而是加载和显示你的窗体视图控制器的定期方式。请注意,您的主控制器中,表单只是显示例如使用BOOL变量,然后处理可能发生的任何点击。如果您的表单显示,请将其解除。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容