結構是login界面登錄驗證通過後跳轉到uitabbarcontroller,
UserListViewController *userListVC = [[UserListViewController alloc]init];
DashboardViewController *dashboardVC = [[DashboardViewController alloc]init];
ProjectOverallViewController *projectOverallVC = [[ProjectOverallViewController alloc]init];
AlertViewController *alertVC = [[AlertViewController alloc]init];
UIViewController *firstNavigationController = [[UINavigationController alloc] initWithRootViewController:userListVC];
UIViewController *secondNavigationController = [[UINavigationController alloc] initWithRootViewController:dashboardVC];
UIViewController *thirdViewController = [[UINavigationController alloc] initWithRootViewController:projectOverallVC];
UIViewController *fourthNavigationController = [[UINavigationController alloc] initWithRootViewController:alertVC];
RDVTabBarController *tabBarController = [[RDVTabBarController alloc] init];
[tabBarController setViewControllers:@[firstNavigationController,secondNavigationController,thirdViewController,fourthNavigationController]];
self.viewController = tabBarController;
其4個子界面在創建的時候勾選了xib,現在是我在4個xib文件設置其背景色無效,代碼設置有效
請問大概是哪裡的問題
子控制器
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"User";
}
return self;
}
對於 xib 文件中的其他元件,如果需要代碼中中間使用:1. 必須對這個元件設置一個自定義的 class 名稱2. 使用類似下邊的代碼去循環找到定義,代碼類似:NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"xib_file_name" owner:self options:nil];for (id oneObject in nib) { if ([oneObject isKindOfClass:[ClassName class]]) { cell = (ClassName *) oneObject; break; }}