【发布时间】:2012-09-05 12:25:55
【问题描述】:
我的项目的当前版本:
我的应用中有 5 个不同的
UIViewControllers。我已经设置了我的FirstViewController成为Initial View Controller使用 属性检查器。我从一个 ViewController 来回移动到 另一种是使用我分配模态序列的按钮,从一个 ViewController 到另一个,使用 StoryBoard
我想要改变的:
我想明显保留导航按钮,删除模态序列并使用
UINavigationController代替。如果我理解这个概念 正确地,当使用UINavigationController时,我需要进入每个UIButton-IBAction在方法的最后,我必须推动下一个 我想移动到的 ViewController 到我的 NavigationController 上(我也 必须先弹出当前的?)。但是,我无法弄清楚如何 正确实施所有这些。
到目前为止我做了什么:
- 我从情节提要中删除了所有模态转场,并保留了导航按钮及其对应的 IBActions
- 我取消选中了属性检查器中使我的 FirstViewController 成为我的应用程序的初始视图控制器的框
- 我进入了我的 AppDelegate.m 并尝试在那里创建导航控制器并使我的 FirstViewController 成为 RootViewController
MyAppDelegate.m
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewController *myFirstViewController = [[FirstViewController alloc] init];
UINavigationController *myNavigationController = [[UINavigationController alloc] initWithRootViewController:myFirstViewController];
[myNavigationController pushViewController:myFirstViewController animated:YES];
// Override point for customization after application launch.
return YES;
}
- 然后我尝试通过进入 IBAction 的 我的 FirstViewController 上的导航按钮并实现了 以下是为了移动到我的 SecondViewController 时 按钮被按下:
FirstViewController.m
- (IBAction)goRightButton:(UIButton *)sender
{
// some code drawing the ButtonIsPressed UIImageView on the current View Controller
UIViewController *mySecondViewController = [[SecondViewController alloc] init];
[self.navigationController pushViewController:mySecondViewController animated:YES];
}
但什么也没发生。我做错了什么?
【问题讨论】:
-
一个赞成票只是为了您的问题清晰。
标签: objective-c ios uiviewcontroller uinavigationcontroller