簡體   English   中英

UITabBarController以編程方式添加,但是標簽欄不顯示

[英]UITabBarController added programmatically, but tab bar doesn't display

我不是從UIWindow開始,而是從UIView開始添加UITabBarController

我在documentFileName有一個文件名數組,希望在子視圖中一個一個地逐個加載它們。

viewControllers = [[NSMutableArray alloc] init];
(NSString *tempStr in documentFileName) {
Subview *subviewController = [[Subview alloc] initWithFileName:tempStr];
    [viewControllers addObject:subviewController];
}
tabBarController.viewControllers = viewControllers;
[self.view addSubview:tabBarController.view];
}

在SubView.m中:

- (id) initWithFileName:(NSString *)fileName {
    isiPhone = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone;
    if (self = [super initWithNibName:((isiPhone)?@"NFLSPromDressingsSubview_iPhone":@"NFLSPromDressingsSubview_iPad") bundle:nil])
    {
        currentFileName = fileName;
    }
    return self;
}

- (void) viewDidLoad {
    [self loadDocuments];
    UITabBarItem *theItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:[documentFileName indexOfObject:currentFileName]];
    self.tabBarItem = theItem;
}

但是,選項卡欄顯示為白色和空白 我在哪里犯錯了? 謝謝。

確保tabBar已正確啟動,並在viewDidLoad方法中添加tabBar以查看[self.view addSubview:tabBarController.view]; self.view [self.view addSubview:tabBarController.view]; tabBarController.view [self.view addSubview:tabBarController.view];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM