我想通过警报视图从AppDelegate推送到视图控制器。但是它不起作用。仅警报视图关闭。问题出在哪里?先谢谢您的帮助。 (NB>我的初始视图在情节提要中,但我正在推入视图控制器笔尖)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

loginReapeat = [NSTimer scheduledTimerWithTimeInterval:60.0 target:self selector:@selector(repeatLoginProcess) userInfo:nil repeats:YES];

//First Launch Settings
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"])
{

}
else
{
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstLaunch"];
    [[NSUserDefaults standardUserDefaults] synchronize];

    [self alertShow];
}

[window addSubview:[navigationController view]];

[window makeKeyAndVisible];

return YES;
}

-(void)alertShow{

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Help!" message:@"Need some help to use this App? Please tap the 'Help' button." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Help",nil];
[alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Help"])
{
    SignUp *signUp = [[SignUp alloc]initWithNibName:@"SignUp" bundle:nil];

    [self.navigationController pushViewController:signUp animated:YES];

}
}

最佳答案

尝试这个:

SignUp *signUp = [[SignUp alloc]initWithNibName:@"SignUp" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:signUp];
self.window.rootViewController = self.navigationController;

关于iphone - 从AppDelegate无法使用pushViewController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16831768/

10-11 07:54