我有一个应用程序,它有一个身份验证屏幕作为它的第一个视图。如果身份验证成功,则加载一个 tabbarcontroller。标签栏中的所有视图都要求用户输入密码。我需要做的是,当用户输入错误密码 5 次时,会弹出一个警报视图,并且应用程序会返回到身份验证屏幕。我能够从超级视图中删除 tabbarcontroller.view。但在那之后屏幕是空白的。不显示验证屏幕。我能做些什么来完成我的任务?
编辑:
- (void) alertView:(UIAlertView *) actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (actionSheet == alertDeActivate) {
if (buttonIndex == 0) {
NSLog(@"Alert Deactivated");
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
if (!window) {
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
[self.tabBarController.view performSelectorOnMainThread:@selector(removeFromSuperview) withObject:self waitUntilDone:YES];
[self.dataLayer notifySplashRemoved];
}
}
}
-(void)notifySplashRemoved
{
bool userAuthenticated = [self checkForUserAuthentication];
bool appAcivated = [self checkForAppActivation];
if (userAuthenticated)
{
if(appAcivated == false){
self.activationScreen = [[ActivationScreen alloc] init];
[self.activationScreen setdataLayer:self];
[self.window addSubview:self.activationScreen.view];
}
else
{
_tbc = [[UITabBarController alloc] init];
manageVRNs = [[ManageVehiclesView alloc] init];
aboutUsView = [[AboutUsView alloc] init];
helpView = [[HelpView alloc] init];
optionsView = [[OptionsView alloc] init];
_manage = [[UINavigationController alloc] initWithRootViewController:manageVRNs];
[_manage.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigation_bar.png"] forBarMetrics:UIBarMetricsDefault];
_about = [[UINavigationController alloc] initWithRootViewController:aboutUsView];
[_about setNavigationBarHidden:YES];
_help = [[UINavigationController alloc] initWithRootViewController:helpView];
[_help.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigation_bar.png"] forBarMetrics:UIBarMetricsDefault];
self.navCon = [[UINavigationController alloc] initWithRootViewController:optionsView];
[self setnavigationCon:self.navCon];
[optionsView setdataLayer:self];
if ([navCon.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
UIImage *image = [UIImage imageNamed:@"navigation_bar.png"];
[self.navCon.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
[optionsView addSelfView:window];
}
_tbc.viewControllers = [NSArray arrayWithObjects:navCon, _manage, _about, _help, nil];
[_tbc.tabBar setBackgroundImage:[UIImage imageNamed:@"menu_bg.png"]];
[_tbc.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"menu_selected.png"]];
[window addSubview:_tbc.view];
}
}
else
{
self.authenticationScreen = [[AuthenticationScreen alloc] init];
[self.authenticationScreen setdataLayer:self];
[self.window addSubview:self.authenticationScreen.view];
}
}