为什么dismissViewControllerAnimated在一种情况下工作,而在另一种情况下不工作?

时间:2017-03-16 14:43:09

标签: ios objective-c

内容控制器推送到导航控制器。

展示解雇导航控制器。

我已尝试了2种向内容控制器添加导航按钮的替代方法关闭UINavigationController ,两种方法都成功调用formDone,但是,第一种方式结果在导航控制器中,即使调用了formDone,WONT也会被解除,而第二个将按预期关闭导航控制器。我甚至无法理解导致这种奇怪行为的原因。

备选方案1:

contentController.navigationItem.leftBarButtonItem = 
    [[UIBarButtonItem alloc] initWithTitle:@"Back" 
                                     style:UIBarButtonItemStylePlain 
                                     target:self 
                                     action:@selector(formDone)];

备选方案2:

contentController.navigationItem.leftBarButtonItem = 
    [[UIBarButtonItem alloc]] initWithBarButtonSystemItem:UIBarButtonSystemItemDone 
                                                   target:self 
                                                   action:@selector(formDone)];

展示代码:

myNavigationController = [[UINavigationController alloc] init];
[myNavigationController pushViewController:contentController animated:YES];
[myPresentingController presentViewController:myNavigationController animated:YES completion:^{}];

解雇代码:

-(void)formDone
    {
        [myPresentingController dismissViewControllerAnimated:YES completion:^{ }];
    }

0 个答案:

没有答案
相关问题