程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> uitabbarcontroller-UITabBarController的子頁面不加載xib?

uitabbarcontroller-UITabBarController的子頁面不加載xib?

編輯:編程綜合問答
UITabBarController的子頁面不加載xib?

結構是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; }}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved