如何在iPhone的摄像头视图中导航上一个屏幕? [英] How to navigate previous screen from camera view in iphone?
问题描述
我是iPhone的新手,我在相机视图中使用自定义后退按钮并使用poptoviewcontroller,它无法正常工作,但是我想当我单击后退按钮导航到主屏幕时如何操作?请任何人帮助我.
Im new to iphone, i have custom back button in camera view and using poptoviewcontroller, its not working, but i want when i click the back button to navigate home screen, how? please any one help me.
我尝试了源代码
backbtn=[UIButton buttonWithType:UIButtonTypeCustom];
backbtn.frame=CGRectMake(40, 10, 80, 40);
[backbtn setBackgroundImage:[UIImage imageNamed:@"backspace.png"] forState:UIControlStateNormal];
[backbtn addTarget:self action:@selector(gotoprevious) forControlEvents:UIControlEventTouchUpInside];
[buttonView addSubview:backbtn];
-(void)gotoprevious
{
NSLog(@"Go to prevoius screen");
Homepage *homepage=[[Homepage alloc]init];
[self.navigationController popToViewController:homepage animated:YES];
}
推荐答案
要从导航控制器堆栈中删除最后一个添加的viewController,请使用:
To remove the last add viewController from the navigation controller stack use:
[self.navigationController popViewControllerAnimated:YES];
您要执行的操作将不起作用,因为您正在创建Homeview视图控制器的新实例,该实例不在堆栈中.
What you are tying to do won't work because you are creating a new instance of the Homepage view controller, which is not in the stack.
popToViewController期望一个已经在堆栈中的viewcontroller实例.
popToViewController is expecting a viewcontroller instance which is already in the stack.
这篇关于如何在iPhone的摄像头视图中导航上一个屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!