如何从一个视图导航到另一视图
我使用按钮操作来弹出子视图,如下代码;
- (IBAction)pickerUpBtn:(id)sender {
PickerPopUpController *screen = [[PickerPopUpController alloc]initWithNibName:@"PickerPopUpController" bundle:Nil];
[self.view addSubview:screen.view];
[self presentModalViewController:screen animated:YES];
}
在我需要去上一个窗口之后;所以我使用了另一个按钮操作,并在操作中添加了以下代码
PickerViewController *screen = [[PickerViewController alloc]initWithNibName:@"PickerViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:screen animated:YES];
,但它不会导航到上一个视图。我怎么能做到呢?
I used button action to to pop sub view sing below code;
- (IBAction)pickerUpBtn:(id)sender {
PickerPopUpController *screen = [[PickerPopUpController alloc]initWithNibName:@"PickerPopUpController" bundle:Nil];
[self.view addSubview:screen.view];
[self presentModalViewController:screen animated:YES];
}
after i need to go previous window; So i used another button action for it and add bellow code inside action
PickerViewController *screen = [[PickerViewController alloc]initWithNibName:@"PickerViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:screen animated:YES];
But It does not navigate to previous view . How could i do it ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
回去,
做
to go back,
do
您只需将单个代码放入按钮操作中。无需创建parentViewController 对象。
IE,
You need to put only that single code in the Button action..No need of making object of parentViewController.
ie,
您需要为您的 ViewController 添加
cancel
和done
,以返回到父视图控制器。实现
Cancel
按钮后,您必须使用dismissModalViewControllerAnimated
在Cancel
按钮的action函数中关闭视图控制器功能You need to add
cancel
anddone
for your ViewController which is present modely to come back to parent view Controller.After implementing the
Cancel
button, you have to dismiss your viewcontroller in the action function ofCancel
button using thedismissModalViewControllerAnimated
function对于推送视图控制器,您可以执行如下操作,
然后要返回,您必须在“屏幕”视图控制器中添加一个按钮,并且您必须编写以下代码的单击事件,
希望这会有所帮助。
如有任何困难请告诉我。
如果您使用的是“presentmodelviewcontroller”方法,那么您必须在按钮单击中写下一行。
For push view controller, you can do like below,
Then for go back, you have to add one button in "Screen" view controller and it's click event you have to write below code,
Hope, it would be helpful.
Let me know in case of any difficulty.
If you are using the method "presentmodelviewcontroller" then you have to write below line in button click.