【问题标题】:How to push automatically [closed]如何自动推送[关闭]
【发布时间】:2012-05-20 10:56:26
【问题描述】:

如果 xml 文件包含超过 1 个文件,我现在正在检查我的应用程序,否则我想将视图控制器自动推送到另一个视图控制器。

我现在正在这样做,但它确实有效!

UIViewController *rootController = [[ViewControllerOne alloc] initWithNibName:@"ViewControllerOne" bundle:nil];

navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];

我需要将数据从第一个视图控制器发送到我通常推送到的视图控制器 (ViewControllerOne) 以执行此操作:

ViewControllerthree *Controller = [[ViewControllerthree alloc] initWithNibName:@"ViewControllerthree" bundle:[NSBundle mainBundle]];

Controller.Title = [item objectForKey:@"Title"];
[self.navigationController pushViewController:Controller animated:YES];
Controller = nil;

我想组合这段代码,这样我就可以“重定向”控制器,如果它在 ViewController 中包含两个东西,它需要在视图控制器中不显示后退按钮的情况下推送它,我将数据推送到

【问题讨论】:

  • 我不明白你的问题。您发布的代码似乎与您的问题无关?
  • 你想在解雇时跳过视图控制器吗?让我们说从C你绕过B回到a?如果是这样,请参阅:stackoverflow.com/questions/2944191/…

标签: objective-c ios cocoa-touch


【解决方案1】:

哈哈,这就是答案!你刚刚发布了答案试试这个;

ViewControllerthree *Controller = [[ViewControllerthree alloc] initWithNibName:@"ViewControllerthree" bundle:[NSBundle mainBundle]];

    Controller.Title = [item objectForKey:@"Title"];
UIViewController *rootController = 
    [[ViewControllerOne alloc] 
     initWithNibName:@"ViewControllerOne" bundle:nil];

    navigationController = [[UINavigationController alloc]
                            initWithRootViewController:rootController];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];
 [self.navigationController pushViewController:Controller animated:YES];
    Controller = nil;

瞧!

祝你好运, 内森

【讨论】:

    【解决方案2】:

    如果没有“返回”按钮,你将如何关闭 UIViewController?

    要隐藏“返回”按钮,请使用以下命令:

    self.navigationItem.hidesBackButton = YES;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-15
      • 1970-01-01
      • 2011-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多