iPhone TabBar selection cancelling
Posted
by Chris Schnyder
on Stack Overflow
See other posts from Stack Overflow
or by Chris Schnyder
Published on 2010-03-31T17:00:51Z
Indexed on
2010/03/31
17:03 UTC
Read the original article
Hit count: 335
iphone
|tabbarcontroller
I am developing an iPhone app that displays several views, all acessed via Tab Bar items. However I need to add an additional item to the Tab Bar that simply launches a URL in Safari.
I've accomplished this by adding an empty placeholder view to the TabBar and returning FALSE from shouldSelectViewController when the this view's tabBarItem is clicked on, and launching Safari at the same time.
That code is:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
if([[viewController tabBarItem] title] == "Website"){
//... launch Safari
return FALSE;
} else {
return TRUE;
}
}
PROBLEM: If the TabBar has too many items, and this "Safari Launch" tab is pushed off to the "More" navigation controller, I lose the capability to intercept the event and prevent the view from loading when clicked.
Any suggested tips?
© Stack Overflow or respective owner