【发布时间】:2013-02-19 12:21:47
【问题描述】:
我是 iOS 编程新手。
我想做的是:
我在情节提要中有一些视图,我想以编程方式在视图之间切换。比如,当一个按钮被点击时,我调用了一个方法,我想在这里改变视图(我可以成功调用该方法)。这些按钮也是以编程方式在不同位置创建的。
我已经搜索过,我认为 NavigationController 会发生这种情况。我有一个这样创建的导航控制器:菜单Editor -> Embed In -> NavigationController。我怎么能用这个NavigationController 做到这一点?
@Madhu 和@Dilip,我找到了xib 归档类的解决方案
icerik *secondViewController = [[icerik alloc] initWithNibName:@"icerik" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
navigationController.topViewController.title = @"SecondViewController";
//[self presentModalViewController:navigationController animated:YES];
if([self respondsToSelector:@selector(presentViewController:animated:completion:)])
[self presentViewController:navigationController animated:YES completion:^{/* done */}];
else if([self respondsToSelector:@selector(presentViewController:animated:)])
[self presentModalViewController:navigationController animated:YES];
我有一个名为icerik 的带有xib 文件的类,我是这样解决的。它正在开放,但当我想回头时,我该怎么办?
【问题讨论】:
-
你想要这样,当用户点击 btn 时,他会从当前视图控制器转到另一个视图控制器,对吧?
-
是的,我想使用情节提要更改两个视图控制器。
标签: ios uiview uinavigationcontroller views navigationcontroller