我有一個帶有橫幅視圖委託的導航欄的程序化tabbar delagate。而對於我的生活,我似乎無法讓標籤在點擊時彈出根視圖。我知道我需要使用像[self.navigationController popToRootViewControllerAnimated:NO];但我不知道把它放在我的應用程序委託中。不能讓tabbar應用程序popToRootViewController
@implementation AppDelegate {
UITabBarController *_tabBarController;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
NSError *setCategoryError = nil;
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:@"Subscription.plist"];
NSDictionary * subscriptionList = [[NSDictionary alloc] initWithContentsOfFile:subscriptionListFile];
NSArray * subscriptionFolders = subscriptionList[@"Folders"];
NewsListViewController * newsController = nil;
UINavigationController * newsNavigationController = nil;
BannerViewController * bannervcs = 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];
bannervcs = [[BannerViewController alloc] initWithContentViewController:newsNavigationController];
[bannervcs.tabBarItem setImage:folderIconImage];
[viewControllers addObject:bannervcs];
}
_tabBarController = [[UITabBarController alloc] init];
_tabBarController.viewControllers = viewControllers;
self.window.rootViewController = _tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
@end
任何想法,我添加popToRootViewController?我在最後嘗試,但它似乎並沒有抓住任何控制器...
採取樣本代碼你在哪裏你tabBarController加入您的導航控制器? – Rajneesh071
我的設置是一個TabBarController,帶有容器BannerViewController,Nav和TableView。在VC被包裝在橫幅之前添加nav,所以如果你NSLOG viewController它返回BannerViewController(1-4),我需要一種方法來獲取所選容器控制器內的導航欄poptoroot。我的下面的代碼只能看到BannerView,而不是子導航視圖。 –
什麼是NewsListViewController? – Rajneesh071