Xcode 故事板切换
有人帮我理解 Xcode 4.2 中的新故事板吗?
我知道如何编写代码来加载另一个视图控制器,但在故事板模式下存在差异。
我也知道有很多关于导航控制器的教程,但我只想在故事板上切换 UIViewController。
使用普通的 .xib 文件,我可以使用 RootViewController 中的代码切换视图。
SecondViewController *Second = [[SecondViewController alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:Second animated:YES];
当我在故事板模式下使用它时,它只是在 SecondViewController.m 上加载 UIAlertView 并且屏幕显示为黑色?
如有任何帮助,我们将不胜感激,还附上了 Xcode 项目...
-x- 杰·鲁本
Someone help me understand the new storyboard in Xcode 4.2?
I know how to code to load another view controller but in the storyboard mode there are differences..
I also know there are a lot of tutorials about the navigationcontrollers, but I just want to switch UIViewControllers on storyboard.
With the normal .xib files I can switch views with this code from the RootViewController..
SecondViewController *Second = [[SecondViewController alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:Second animated:YES];
When I use it in the storyboard mode it just loads the UIAlertView on the SecondViewController.m and the screen appears to be black?
Any help would be appreciated, also attached the Xcode project...
-x- Jay Ruben
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以这样做:
不要忘记给第二个视图控制器一个像“第二”这样的标识符。
否则,您可以使用 segue 连接两个视图控制器。按住 CTRL 键从第一个视图控制器拖动到第二个视图控制器。现在,您可以选择“push”并为 Segue 指定一个名称,以便以编程方式切换视图,如下所示:
Push Segues 仅在设置了导航控制器时才起作用。
you can do this:
Don't forget to give the second view controller an identifier like "second".
Otherwise you can connect both view controllers with a segue. Hold CTRL an drag from the first to the second view Controller. Now you can choose "push" and give the segue a name to switch the View programmatically like this:
Push Segues will only work if a navigation controller is set.
您还可以通过以下方式进行切换:
此处下载示例项目。
You can also switch this way:
Download the sample project here.