UITabBarController 的两种初始化

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

其中:

1、viewController = [[ViewController alloc]init];

viewController.m里

-(id)init{

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

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

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

}

return self;

}

2、用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;

}

你可能感兴趣的:(UITabBarController 的两种初始化)