2012-11-08 19 views
0

我有一個plist,填充標籤欄上的所有內容,包括tableview:標籤名稱,標籤圖標,標題,細節,並使VC進入viewControllers數組。 「Banner VC alloc with content view controller:viewControllers」 - 不接受數組,只接受單個VC或多個VC(如果它們已知的話)。 這些標籤是可變的,他們可以移動和更改,所以我不能單獨編程它們。如何將未知的選項卡數組傳遞給bannerview控制器?橫幅VC不會加載從plist陣列

下面非常接近,但橫幅vc將只顯示在plist中的最後一個集合,而不是整個集合......並且如果我嘗試將viewControllers數組傳遞給它,就會崩潰。

即時通訊問的是什麼...你如何加載一個內置5個標籤的plist的banner 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 :(
+1

BannerViewController的一個子類是什麼類? – rdelmar

+0

它直接來自iAd suite oct24th,標籤式橫幅示例。它只是一個uivc。 –

回答

0

的方法,initWithContentViewController :,因爲你可以從它的名字(控制器不控制器)告訴,只接受一個視圖控制器作爲其參數。目前還不清楚你想做什麼,因爲該方法是UIPopoverController的一種方法,並且你通常不會在TabBar控制器的viewControllers中將一個popover控制器變成一個控制器。

+0

我試圖加載一個標籤欄到iAd容器vc。 for循環創建選項卡並將其展示給viewControllers,然後將其設置爲tabbar控制器。我不能做的是將一個數組加載到bannerVC alloc中,我不能像「banner vc alloc vc1,vc2,vc3」那樣單獨執行它們 - 因爲我不知道開頭的選項卡數量。它的工作方式,如果我跳過bannerVC的方式。或者,也許我只是在我的頭... –

+0

_tabBarController = [[UITabBarController alloc] init]; _tabBarController.viewControllers = @ [ [[BannerViewController的alloc] initWithContentViewController:originalIpsumViewController], [[BannerViewController的alloc] initWithContentViewController:meatyIpsumViewController], [[BannerViewController的alloc] initWithContentViewController:veganIpsumViewController], ]; 這是蘋果的例子,但我有一個for循環,而不是一個VC的定義數量 –

+0

也許我只是有一個腦屁,也許如果我把它放在for循環以某種方式... –