Ian Vink
Ian Vink

Reputation: 68750

UISegmentedControl on a UITableViewController

I have a UITableViewController hosted in a NavigationController which is in a Tab.

I wish to have a UISegmentedControl float over the table so that as the table scrolls, the UISegmentedControl is visible.

To what subview do I add the UISegmentedControl?

Upvotes: 1

Views: 700

Answers (1)

Niels Castle
Niels Castle

Reputation: 8069

Try adding your UISegmentedController to your UINavigationController as a UIBarButtonItem with something along the lines of:

UISegmentedController * sc = ...
sc.segmentedControlStyle = UISegmentedControlStyleBar;

UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc]
                                      initWithCustomView:segmentedControl];

myUINavigationController.navigationItem.rightBarButtonItem = segmentBarItem;

-- if you want to have the UISegmentedController float on top of your table (obscuring it) you should add a transparent UIView that sits above the UITableView and stick it in there. But that's probably not what you want.

Upvotes: 1

Related Questions