我在推送视图控制器时遇到了问题。这就是我所做的:点击一个按钮,我使用下面的代码添加一个模式视图,它工作得很好:
- (void)addAction:(id)sender
{
uipickerForContract *addViewController = [[uipickerForContract alloc] initWithNibName:@"uipickerForContract" bundle:nil];
addViewController.delegate = self;
addViewController.modalPresentationStyle = UIModalPresentationFormSheet;
addViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:addViewController animated:YES];
addViewController.view.superview.frame = CGRectMake(50, 740, 695, 245);
}这个添加的视图控制器包含一个完成按钮,我想使用它来导航到其他视图控制器:所以我使用了该代码,但它不起作用,它只是关闭了addeview:
donebutton{
nextview*s = [[nextview alloc]initWithNibName:@"nextview" bundle:nil];
s.view.frame = CGRectMake(10, 20, 745, 755);
//nextview contains the object that I want to pass :object
s.object= self;
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self];
[self dismissModalViewControllerAnimated:YES];
[self.navigationController pushViewController:s animated:YES];
NSLog(@"self.nav%@",self.navigationController);
}发布于 2013-05-27 22:50:42
视图控制器(您以模态方式呈现)的self.navigationController将为零
您无法注意到这一点,因为您正在分配导航控制器对象。
发布于 2013-05-27 19:55:45
您需要在解除和下一次推送之间设置一些延迟,就像这样
之前的 :
nextview*s = [[nextview alloc]initWithNibName:@"nextview" bundle:nil];
s.view.frame = CGRectMake(10, 20, 745, 755);
//nextview contains the object that I want to pass :object
s.object= self;
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self];
[self dismissModalViewControllerAnimated:YES];
[self.navigationController pushViewController:s animated:YES];
NSLog(@"self.nav%@",self.navigationController);之后的
[self dismissModalViewControllerAnimated:YES];
[self performSelector:@selector(pushNextView) withObject:nil afterDelaye:0.40];
- (void) pushNextView {
nextview*s = [[nextview alloc]initWithNibName:@"nextview" bundle:nil];
s.view.frame = CGRectMake(10, 20, 745, 755);
//nextview contains the object that I want to pass :object
s.object= self;
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self];
[self.navigationController pushViewController:s animated:YES];
NSLog(@"self.nav%@",self.navigationController);
}https://stackoverflow.com/questions/16772503
复制相似问题