[英]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.