我有一个 plist,它填充了选项卡栏上的所有内容,包括 tableview:选项卡名称、选项卡图标、标题、详细信息,并将 VC 放入 viewControllers 数组。“带有内容视图控制器的横幅 VC 分配:viewControllers” - 不接受数组,仅接受单个 VC,或多个 VC(如果它们已知)。选项卡是可变的,它们可以移动和更改,所以我不能单独对它们进行编程。如何将未知的选项卡数组传递给横幅视图控制器?
下面非常接近,但横幅 vc 只会显示 plist 中的最后一组,而不是整个组......如果我尝试将 viewControllers 数组传递给它,它只会崩溃。
我要问的是...你如何用一个内置 5 个标签的 plist 加载横幅 vc?
提前谢谢。如果我偏离了路线,有人可以试着欺负我。我真的不想将自己限制在只有 5 个标签上。
我只是在 plist 中添加一个键,它会自动将一个选项卡添加到更多部分......我如何通过 bannew VC 传递这个?
_tabBarController.viewControllers = viewControllers; //Loads the array viewControllers fine with 5 tabs and icons, but no banner container
_tabBarController.viewControllers = @[[[BannerViewController alloc] initWithContentViewController:viewControllers]] // Crashes on launch
_tabBarController.viewControllers = @[[[BannerViewController alloc] initWithContentViewController:newsNavigationController]] // Loads only the last key in plist and with no icons
@implementation AppDelegate {
UITabBarController *_tabBarController;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CGRect bounds = [[UIScreen mainScreen] bounds];
self.window = [[UIWindow alloc] initWithFrame:bounds];
self.window.backgroundColor = [UIColor whiteColor];
NSMutableArray * viewControllers = [[NSMutableArray alloc] init];
NSString * subscriptionListFile = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"My_Subscription.plist"];
NSDictionary * subscriptionList = [[NSDictionary alloc] initWithContentsOfFile:subscriptionListFile];
NSArray * subscriptionFolders = subscriptionList[@"Folders"];
NewsListViewController * newsController = nil;
UINavigationController * newsNavigationController = nil;
for (NSDictionary * folderDetails in subscriptionFolders) {
NSArray * newsItems = folderDetails[@"Items"];
NSString * folderTitle = folderDetails[@"FolderName"];
NSString * folderIcon = folderDetails[@"FolderIcon"];
UIImage * folderIconImage = [UIImage imageNamed:folderIcon];
newsController = [[NewsListViewController alloc] initWithNewsSourceList:newsItems];
[newsController setTitle:folderTitle];
newsNavigationController = [[UINavigationController alloc] initWithRootViewController:newsController];
[newsNavigationController setTitle:folderTitle];
[newsNavigationController.tabBarItem setImage:folderIconImage];
[viewControllers addObject:newsNavigationController];
}
_tabBarController = [[UITabBarController alloc] init];
// _tabBarController.viewControllers = viewControllers; <--- this line works, below doesnt load the array...
_tabBarController.viewControllers = @[[[BannerViewController alloc] initWithContentViewController:viewControllers]]
self.window.rootViewController = _tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
@end //The above crashes, but works fine if I SKIP "BannerViewController alloc..."
//and go right to "_tabBarController.viewControllers = viewControllers"
//perfect but no adbanner :(