最近刚学习IOS,现有一个登陆界面,还有一个包含多个选项卡的界面
在点击登陆界面的登陆按钮时跳转至含tabbar的界面,我该怎么实现了?
希望有人能给出思路,如果有关键代码最好了
在ViewController.m中登陆按钮的代码如下
UIViewController *controller=[[Tabbarcontroller alloc]init];[self presentModalViewController:controller animated:YES];
在TabbarController.h中
@property(strong,nonatomic) UITabBarController *controller;
然后是在TabbarController.m中的
@synthesize controller;-(id) initWithNibName(NSString *)nibNameOrNil bundle:(NSBundle *)nibBoundleOrNil { self=[super initWithNibName:nibNameOrNil bundle:nibBoundleOrNil]; UIViewController *first=[[First alloc]initWithNibName:@"First" bunlde:nil]; UIViewController *second=[[Second alloc]initWithNibName:@"Second" bunlde:nil]; controller=[[UITabBarController alloc]init]; controller.viewControllers=[NSArray arrayWithObjects:first,second,nil]; [self.view addSubView:controller.view]; if(self){ } return self; }
效果出来了 但是tabbar感觉是整体下移了一些位置(头部有一些空白,tabbar选项卡底部被遮盖了)
海绵宝宝撒
相关分类