开发者

How to use a segmented control in the toolbar to switch views?

开发者 https://www.devze.com 2023-04-05 07:44 出处:网络
As it has been asked many times, I am trying to switch views by using a segmented control correctly. I cannot just hide/display because the views are too complicated.

As it has been asked many times, I am trying to switch views by using a segmented control correctly. I cannot just hide/display because the views are too complicated.

I have gotten it to work using this solution from this answer, but this places the segmented control in the title bar. I would like to palce it on the bottom, in a toolbar.

I have tried hooking it up via IB and declaring each开发者_StackOverflow社区 subviews control, but no luck. I think it has something to do with the @selector section.

Can someone please shed some light on this for me?


UIBarButtonItem *item = [[[UIBarButtonItem alloc] initWithCustomView:segmentedControl] autorelease];

// if you are in a navigation controller:

[self.navigationController setToolbarHidden:NO];
self.toolbarItems = [NSArray arrayWithObject:item];

// else, created a UIToolBar called toolBar at the bottom of the view and...

toolBar.items = [NSArray arrayWithObject:item];
0

精彩评论

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