开发者

How to change number of tabs in tabbar controller application?

开发者 https://www.devze.com 2022-12-18 08:16 出处:网络
I am developing an iPhone tabbar application wi开发者_高级运维th 5 tabs . I want to show only two tabs at the launch time such as one is \"locate me\".

I am developing an iPhone tabbar application wi开发者_高级运维th 5 tabs .

I want to show only two tabs at the launch time such as one is "locate me".

When the user taps on the locate me tab another 3 tabs will be shown and can use the current location.

I want to do some thing like "urban spoon" .

I am using the interface builder for all the stuff.

If any one have any idea , suggestion , links then provide me.

Thanks .


// Make array which includes your existing view controllers
NSMutableArray *newVCs = [NSMutableArray arrayWithArray:[yourTabBarController viewControllers]];

// First new VC you want to add (example from a nib)
[newVCs addObject:[[[SomeCustomViewController alloc] initWithNibName:@"yourNibName" bundle:[NSBundle mainBundle]] autorelease]];

// Second new VC you want to add (example for a VC generated from code)
[newVCs addObject:[[[AnotherCustomViewController alloc] initWithNibName:nil bundle:nil] autorelease]];

// Third new VC you want to add (example from IBOutlet)
[newVCs addObject:self.yetAnotherViewController];

// Set the tab bar's view controllers to your new modified array
[yourTabBarController setViewControllers:newVCs];


-[UITabBarController setViewControllers:] => You can give the tab bar controller a new array of view controllers, and it will replace its existing tabs with new tabs that correspond to the view controllers in the new array.

0

精彩评论

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

关注公众号