UITabBarController 的两种初始化

在deletegate.m里用代码生成的TabBarController spa

其中: it

一、viewController = [[ViewController alloc]init]; im

viewController.m里 tab

-(id)init{ view

if((self=[super init])){ vi

self.tabBarItem.image = [UIImage imageNamed:@"news"]; let

self.tabBarItem.title=@"标题"; 生成

} new

return self; return

}

二、用nib生成的view

如:

self.albumViewController = [[AlbumViewController alloc]initWithNibName:@"AlbumViewController" bundle:nil];

在albumViewController.m里

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if(self){

self.tabBarItem.image = [UIImage imageNamed:"album"];

self.tabBarItem.title = @"相册";

}

return self;

}

相关文章
相关标签/搜索