navigationController不会返回rootViewController

时间:2015-05-28 11:18:50

标签: ios objective-c xcode uinavigationcontroller cocoapods

我已将第三方库导入到我的项目中。在我的AppDelegate中,我创建了一个navigationController并将rootViewController设置为我现有的项目主视图。然后我引用库ViewController并将其呈现在导航堆栈上(我认为)。它会显示但当我尝试解雇并返回原始项目视图时它不起作用。我的代码:

AppDelegate.m

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        appbarViewController = [[AppBarViewController alloc] init];
        self.navigation = [[UINavigationController alloc]initWithRootViewController:appbarViewController];
        self.window.rootViewController = self.navigation;
        [self.navigation setNavigationBarHidden:NO];
        [self.window addSubview:self.navigation.view];
        [self.window makeKeyAndVisible];
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
        }
        return YES;
    }

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if([[url host] isEqualToString:@"session"]){

        if([[url path] isEqualToString:@"/login"])
        {

    ACSViewController *acs = [[ACSViewController alloc] init];     
[self.window.rootViewController presentViewController:acs animated:NO completion:nil];
    }
}
            return YES;
        }
    }

ACSViewController不是库的一部分,我创建并从库类中调用。

libraryViewController.m

-(void)backButtonPressed
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

为什么观点不会被忽视的任何想法?它会动画,但会以相同的当前视图返回。

1 个答案:

答案 0 :(得分:0)

.second { float: left; margin-left: 5px; } dismissing viewcontrollernot,因此动画发生但返回的视图相同。

您在这里展示presented并解雇ACSViewController

解决方案首先删除libraryViewController的视图,然后关闭ACSViewController。下面的代码行应该在libraryViewController中以解除它。

ACSViewController