从UINavigationController弹出UIViewController的问题

时间:2013-10-08 13:48:49

标签: ios uiviewcontroller uinavigationcontroller

我正在为iOS上的用户身份验证开发一个静态库。

单击一个按钮,开发人员将调用我的库的方法并传递UINavigationController的当前引用,如下所示:

LoginViewController *LoginView = [LoginViewController alloc]init];
[LoginView ShowLoginScreen : self.navigationController];

ShowLoginScreen:pRootNavController方法中,我创建了一个带有取消按钮的新UIViewController,并将其添加到navigationController,如下所示:

LoginViewController * loginscreen = [[LoginViewController alloc] initWithNibName:nil bundle:nil];
self.vRootNavController = pRootNavController 
// provide a funnction here eg ShowLoginScreen( self.navigationController )
[self.vRootNavController pushViewController:loginscreen animated:YES];
[self.vRootNavController setNavigationBarHidden:YES animated:YES];

NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.vRootNavController.viewControllers];
int size = [navigationArray count];
NSLog(@"No of view controllers are %d",size);

这是记录No of view controllers are 2

点击Cancel按钮,我想从UIViewController中弹出当前self.vRootNavController。在Cancel按钮的事件处理程序中,我这样做:

[self.vRootNavController popViewControllerAnimated:YES];

SMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.vRootNavController.viewControllers];    
int size = [navigationArray count];
NSLog(@"No of view controllers are %d",size);

问题在于,点击Cancel按钮时,当前UIViewController未被删除,并且正在记录No of view controllers are 0

我做错了什么?

0 个答案:

没有答案