I have added tabbarcontroller programmatically and then added two viewcontrollers to it.The code for the same is:
ExampleViewcontroller.m
self.tabController = [[UITabBarController alloc] init];
viewController1 =[[invoiceviewcontrolleralloc]
initWithNibName:@"invoiceviewcontroller" bundle:nil];
viewController1.title = @"Unpaid Invoice";
viewController2=[[remittanceviewcontrolleralloc]
initWithNibName:@"remittanceviewcontroller" bundle:nil];
tabController.view.frame = CGRectMake(0, 0, 320, 460);
self.tabController.viewControllers = [NSArray arrayWithObjects:
viewController1,viewController2,nil];
[self.view addSubview:tabController.view];
tabController.delegate=self;
self.view bringSubviewToFront:tabController.view];
and the method of tabbarcontroller is as follows:-
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:
(UIViewController *)viewController
{
if(tabController.selectedIndex==0)
{
[viewController2.view removeFromSuperview];
[self.view addSubview:viewController1.view];
}
else if(tabController.selectedIndex==1)
{
[viewController1.view removeFromSuperview];
[self.view addSubview:viewController2.view];
}
[self.view bringSubviewToFront:tabController.view];
}
The code runs fine but the moment I click on the second tab the viewcontroller attach to loses interactivity i.e the functionality in it does not respond to click.