如何在iOS SDK4.2(故事板)中使用分段控件更改视图控制器?需要示例代码
我发现了关于“使用 UISegmentedControl 切换视图”的很棒的示例代码。
http://redartisan.com/blog?page=2
(示例代码链接:http://github.com/crafterm/SegmentedControlRevisited)
但是这个示例代码正在使用xib。我想使用故事板(没有 xib)重新编码它。 有类似的示例代码吗?
I found this great sample code about 'Switching Views with a UISegmentedControl'.
http://redartisan.com/blog?page=2
(sample code link : http://github.com/crafterm/SegmentedControlRevisited)
but this sample code is using xib. I want to re-coding it using storyboard (no xib).
Is anywhere similar sample code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我做了一个小技巧,以便能够在故事板中做到这一点。
我有一个带有主视图和详细视图的 SplitView 控制器。我创建了两个简单的视图控制器,其大小等于详细信息。它们都有一个分段控件,带有相同的两个按钮:第一和第二。在每个视图上,我添加了一个代表该视图的标签(“第一个视图”和“第二个视图”)。
然后,在第一个视图上,我选择“第一个”按钮,在第二个视图上,我选择“第二个”按钮。
之后,唯一剩下的就是在它们之间创建转场(第一个视图转到第二个视图,第二个视图转到第一个视图)。它们的segue 类型都是“replace”。
I did a little trick to be able to do that within the Storyboard.
I have a SplitView Controller with a Master and a Detail view. I created two simple View Controllers with size equal to Detail. Both of them have a Segmented Control with the same two buttons: First and Second. On each view, I added a label representing that View ("First View" and "Second View").
Then, on the first View, I select the "First" button and on the second View, I select the "Second" button.
After that, the only thing remaining is to create segues between them (First View goes to the second and the Second View goes to the First). The type of segue for both of them is "replace".