If i go straight to the point then my problem is i have an UIViewController with two button.
Button One --(onclick must navigate to)---> UITabbarController
with 4 UITabbar
item or i can take a UITabbar
in my new UIViewController
;
Button Two --(OnClick must navigate to)---> UITabbarController
where first tabbaritem
will contain containing UITableView
or or i can take a UITabbar
in my new UIViewController
where first TabbarItem
will contain a UITableView
.
How can i make this??? sample code will more helpful neither suggestion. if you need any clarification please do not hesitate to ask.
With Best Regards Emon
First, you need to have a NavigationController if you want another view controller to be pushed on when you click a button. The steps you would need to do are the following
In the view did appear of the view controller have the following code
self.tbc1 = [[UITabBarController alloc] init]; self.tbc2 = [[UITabBarController alloc] init]; UIViewController *tbc1vc1 = [[UIViewController alloc] init]; UIViewController *tbc1vc2 = [[UIViewController alloc] init]; UIViewController *tbc1vc3 = [[UIViewController alloc] init]; UITableViewController *tbc2vc1 = [[UITableViewController alloc] init]; UIViewController *tbc2vc2 = [[UIViewController alloc] init]; UIViewController *tbc2vc3 = [[UIViewController alloc] init]; [self.tbc1 setViewControllers:[NSArray arrayWithObjects:tbc1vc1,tbc1vc2,tbc1vc3, nil]]; [self.tbc1 setViewControllers:[NSArray arrayWithObjects:tbc2vc1,tbc2vc2,tbc2vc3, nil]];
Ofcourse you have to have properties defined for tbc1 adn tbc2 in your view controller.
In the app delegate do the following
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; ViewController *myViewController = [[ViewController alloc] init]; self.viewController = [[UINavigationController alloc] initWithRootViewController:myViewController]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES;
Change the UIViewController in the .h file to UINavigationController like
@property (strong, nonatomic) UINavigationController *viewController;
Have the two buttons and wire it to the following methods
-(IBAction)tbc1Clicked{ [self.navigationController pushViewController:self.tbc1 animated:YES]; } -(IBAction)tbc2Clicked{ [self.navigationController pushViewController:self.tbc2 animated:YES]; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.