首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >推送UINavigationController

推送UINavigationController
EN

Stack Overflow用户
提问于 2013-05-27 19:45:41
回答 2查看 127关注 0票数 1

我在推送视图控制器时遇到了问题。这就是我所做的:点击一个按钮,我使用下面的代码添加一个模式视图,它工作得很好:

代码语言:javascript
复制
- (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:

代码语言:javascript
复制
 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);
     }
EN

回答 2

Stack Overflow用户

发布于 2013-05-27 22:50:42

视图控制器(您以模态方式呈现)的self.navigationController将为零

您无法注意到这一点,因为您正在分配导航控制器对象。

票数 0
EN

Stack Overflow用户

发布于 2013-05-27 19:55:45

您需要在解除和下一次推送之间设置一些延迟,就像这样

之前的 :

代码语言:javascript
复制
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);

之后的

代码语言:javascript
复制
[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);
}
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16772503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档