我不是从 a 开始,UIWindow
而是从 aUIView
添加我的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;
}
但是,选项卡栏似乎是白色和空的。我在哪里犯了错误?谢谢。