我正在为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
。
我做错了什么?