【发布时间】:2017-05-11 07:23:42
【问题描述】:
我将视图控制器呈现为弹出窗口,并且在弹出视图控制器中我有一个按钮,单击该按钮我试图推动视图控制器,但单击时没有任何反应。如何执行此操作?
将视图控制器显示为弹出窗口
- (IBAction)sendOTPAction:(id)sender {
HMResetPasswordViewController *resetPassword = [self.storyboard instantiateViewControllerWithIdentifier:@"HMResetPasswordViewController"];
// configure the Popover presentation controller
resetPassword.modalPresentationStyle = UIModalPresentationPopover;
resetPassword.preferredContentSize = CGSizeMake(self.view.frame.size.width-10, 375);
resetPassword.popoverPresentationController.delegate = self;
resetPassword.popoverPresentationController.permittedArrowDirections = 0;
resetPassword.popoverPresentationController.sourceView = self.view;
resetPassword.popoverPresentationController.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0);
[self presentViewController:resetPassword animated:YES completion:nil];
}
试图从弹出视图控制器推送视图控制器
- (IBAction)resetButtonAction:(id)sender {
HMLoginViewController *HMLoginViewController= [self.storyboard instantiateViewControllerWithIdentifier:@"HMLoginViewController"];
[self.navigationController pushViewController:HMLoginViewController animated:YES];
}
【问题讨论】:
-
简单,您的 HMResetPasswordViewController 应该嵌入到 UINavigationController 中。您没有导航控制器并试图在导航上推送其他控制器。
-
@Imad 是正确的,将您呈现的视图控制器嵌入到导航堆栈中,然后尝试推送。你的问题将得到解决。 :)
-
很抱歉,但是在“呈现”的 ViewController 上“推送”并不是一个好的设计。尝试呈现而不是推送,这将带来更好的用户体验
-
@Imad,@iPeter 如果我将
HMResetPasswordViewControlller嵌入到UINavigationController中并呈现它,它将全屏显示而不是弹出窗口,我希望它显示为弹出窗口
标签: ios objective-c navigation pushviewcontroller presentviewcontroller