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;

}

相關文章
相關標籤/搜索