[英]Banner VC wont load from plist array
我有一個plist,可填充選項卡欄上的所有內容,包括tableview:選項卡名稱,選項卡圖標,標題,詳細信息,並將VC放入viewControllers數組中。 “帶有內容視圖控制器的橫幅VC分配:viewControllers”-將不接受數組,僅接受單個VC,或者接受多個VC(如果已知)。 這些選項卡是可變的,它們可以移動和更改,因此我無法對其進行單獨編程。 如何將選項卡的未知數組傳遞給Bannerview控制器?
下面非常接近,但是橫幅vc將僅顯示plist中的最后一個集合,而不顯示整個集合...並且如果我嘗試將viewControllers數組傳遞給它,它將崩潰。
我要問的是...如何用一個內置有5個選項卡的plist加載標題vc?
提前謝謝。 如果我偏離路線,可以有人企圖拖我。 我真的不想限制自己只能使用Onyl 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 :(
正如您可以從其名稱(控制器而不是控制器)中看到的那樣,方法initWithContentViewController:僅接受一個視圖控制器作為其參數。 還不清楚您要做什么,因為該方法是UIPopoverController的方法,並且通常不會使popover控制器成為tabBar控制器的viewControllers中的控制器之一。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.