繁体   English   中英

Banner VC不会从plist数组加载

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM