开发者

Switching views with segmented controller iphone

I present a UIViewcontroller modally. On this screen I want a UIToolbar at the bottom with a segmented controller with 2 options. What is the correct way of doing this, I want the toolbar and segme开发者_StackOverflow中文版nted controller to be visible on both uiviewcontroller that the user can toggle between. One approach would be to add a toolbar and segmented controller to both viewcontrollers but this would duplicate the code, and probaly is not correct way of doing it.

Any help much appriciated.


perhaps over simplifying but can you not just swap out a view thats on the modal view controller, or even just have two views on the modal view controller one in front of the other and simply hide the one you dont wish to be displayed based on the toggle of the UISegmentedControl


The same way as Apple did the tabviewcontroller: Your modal viewcontroller manages the toolbar and segment control. Whatever is shown above that toolbar is managed by two more viewcontrollers, ownded by the modal viewcontroller.


I have done this before by having a main view, and two subviews (for lack of a better term).

Basically, the main view will hold the segmented controller, and whatever other UI components you want. Then, based on the selected option of the segmented controller, add the appropriate subview to the main view. Notice, you may need to resize you subviews to fit the space properly. Fairly straightforward to implement and functions quite well. Hope that helps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜