Starting from the spliview master/detail example I found in the SDK, I end up having an iPad app that has a master on the left hand side in landscape, whereas in portrait a button called "Master" allows displaying the master.
To display this button the following code is used
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = @"Master";
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
In my app the master view will be some kind of search view, so I would like the button called master to be displaying the system provided search icon.
First of all I simply do not know how to programmatically (at runtime) add a system icon to a button ? I know how to select it in the storyboard in Xcode at development time but not at runtime.
As I don't know how to do it, for testing purpose I add a right bar button on the top of the bar and I simply assign its image to the master button, like this :
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
//barButtonItem.title = @"Master";
barButtonItem.image = searchBarButton.image;
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
And the result is that the master button simply does not display.
I repeat, this is just for testing purpose, finally I would like to simply assign the system provided search icon.
So my 2 questions are :
- Why is the master button not displaying ? Am I obligated to use "text" for this button
- How do I assign a system provided icon (at runtime) to such a button ?
Anyone can help me ?