xcode 4.2 故事板标识符
我正在编写一个应用程序,其中通过代码向我的视图(mainView)添加一些按钮。当用户点击此按钮时,我希望显示一个新视图(resultView)。
我的故事板中有这两个视图,但由于故事板中的 mainView 上没有按钮,我无法使用故事板将 mainView 和 resultView 相互链接。一切都必须通过代码来完成。
我想知道如何通过代码链接我的两个视图并为该链接定义标识符。
谢谢,
I'm writing an app in which I add some buttons to my view (mainView) by code. When the user taps on this buttons I want a new view (resultView) to show.
I have both of this views in my storyboard, but since there is no button on my mainView that is in storyboard I can't link the mainView and resultView to each other using storyboard. Everything must be done by code.
I want to know how I can link my two views by code and define an identifier for that link.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要以编程方式切换视图控制器,您必须在“视图控制器”部分的属性检查器中设置标识符。之后,您可以在代码中使用该值。这里我使用了标识符“Menu”。
文档里也有说明,随便找一下
To switch the view controller programmatically, you have to set a identifier in the attribute inspector at section "View Controller". After that, you can just use the value inside your code. Here i used the identifier "Menu".
There is also a description in the documentation, just look for
在 IB 的属性检查器中为两者之间的 Segue 指定一个标识符,然后在按钮按下事件上调用
[self PerformSegueWithIdentifier:@"MySegueIdentifier" sender:theButton]
Give the segue between the two an identifier in the Attribute Inspector in IB, then on your button press event call
[self performSegueWithIdentifier:@"MySegueIdentifier" sender:theButton]