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