I have a plist that populates everything on the tab bar including the tableview: tab name, tab icon, title, detail, and makes the VCs into viewControllers array. "Banner VC alloc with content view controller : viewControllers" - wont accept an array, only a single VC, or multiple VCs if theyre known. The tabs are mutable, they can move and change, so I cant program them individually. How do I pass an unknown array of tabs to a bannerview controller?
Below is very close, but banner vc will only display the last set in the plist, not the whole set...And will just crash if I try passing viewControllers array to it.
What im asking is... How do you load banner vc with one plist that has 5 tabs built in it?
Thanks ahead of time. And if im way off course could someone please attempt to stear me. I really dont want to limit myself to onyl 5 tabs.
I just add a key to the plist and it automaticlly ads a tab to the more section... How do I pass this through 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 :(
The method, initWithContentViewController:, as you can tell from its name (controller not controllers), accepts only one view controller as its argument. It's not quite clear what you're trying to do, since that method is a method of UIPopoverController, and you wouldn't normally make a popover controller one of the controllers in a tabBar controller's viewControllers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.