I want to load a tabBarController with no tabBar selected. Actually each tabBarItem corresponds to a certain ViewController.But I have a view “Success” and it doesnot belong to any tabBarItem.So when Successview appears then I need a tabBarController with three tabBarItems (Search,Settings) need to appear and when any tabbaritem is then selected then corresponding ViewController should appear and SuccesView should disappear.
Gone through google and find out this but couldn’t make it working.
In SuccessView.m
- (void)viewDidLoad
{
[super viewDidLoad];
// UIlabels and UITextFields loads
SuccessView *defaultView = [[SuccessView alloc]initWithNibName:@"SuccessView" bundle:[NSBundle mainBundle]];
[self.tabBarController setSelectedViewController:nil];
[self.tabBarController setSelectedViewController:defaultView];
SearchView *first = [[SearchView alloc] initWithNibName:@"SearchView" bundle:nil];
first.title=@"Search";
Settings *second=[[Settings alloc]initWithNibName:@"Settings" bundle:nil];
second.title=@"Settings";
NSArray *viewArray= [NSArray arrayWithObjects:first,second, nil];
tabbarController=[[UITabBarController alloc] init];
[tabbarController setViewControllers:viewArray animated:NO];
[self presentModalViewController:tabbarController animated:NO];
}
But I dont find any tabbarController added to SuccessView.Where I m going wrong?
Even i had the same situation i used
UITabbarand tabbar items instead ofUITabBarControllerbecauseUITabBarControllerexpects a current view from any of the tabbar items placed… Here’s the code..This should get you going:)Make sure you add the delegate
UITabBarDelegatein your header file to implement this methodHope this answers your question and helps:)
Also,we can customize the
UITabbarwith an image…do let me know..i will post the code in here if you want.