Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITabBarController: switch to a different view controller programmatically

Tags:

In my iPhone app, to restore previously viewed tab, on launch I set the setSelectedIndex: (also tried setSelectedViewController: as per docs but to no avail)

This works on iPhone OS 3.0 - however on OS 2.x the selected index greater than 3 (the first 4 tabs) doesn't switch to the required view. This is documented by Apple here: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITabBarController_Class/Reference/Reference.html#//apple_ref/occ/instp/UITabBarController/selectedViewController

Im wondering if its possible to switch to a view controller under iPhone OS 2.x ? Any help is appreciated.

Btw on my simulator setting index greater than 3 throws an error (for iPhone OS 2.x) - so I have wrapped this in a @try{..} @catch(id ..){ } block - hope this technique helps someone.