当我点击下面的按钮 informationBtn_clicked
时,我遇到了一个奇怪的问题。 InformationView
来了。
主视图
-(IBAction)informationBtn_clicked:(id)sender{
InformationView *obj_Info=[[InformationView alloc] initWithNibName:@"InformationView" bundle:nil];
UINavigationController *navigationObj = [[UINavigationController alloc] initWithRootViewController:obj_Info];
[self.navigationController presentModalViewController:navigationObj animated:YES];
}
NextView
点击后面的 btn 后关闭 View Controller ;
-(void)btnBackClicked:(id)sender{
[self dismissModalViewControllerAnimated:YES];
}
在这里,我的问题是当我关闭 NextView 时,再次调用主视图的 viewDidLoad
方法。我的项目在 iOS 5 中运行,我使用的是 ARC。
我正在检查一种方法,即发布 obj_Info
但结果相同请帮助我,我的英语很差,请尝试理解我。
最佳答案
问题在于:
UINavigationController *navigationObj = [[UINavigationController alloc] initWithRootViewController:obj_Info];
您使用 obj_Info
初始化导航 Controller 作为 Root View Controller 。因此,当您关闭模态视图 Controller 时,导航 Controller 会显示其 Root View Controller ,它恰好与模态视图 Controller 相同。
尝试更改我提到的行:
UINavigationController *navigationObj = [[UINavigationController alloc] init];
关于iphone - 关闭/呈现模态视图 Controller - viewdidLoad 再次调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9441642/