2014-09-23 34 views
0

我正在迁移应用程序以与ios8兼容。viewWillAppear正在运行,即使viewDidLoad执行Segue

为什么viewWillAppear块在viewDidLoad执行segue时运行?它不在ios7中发生。

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [self performSegueWithIdentifier:@"showLogin" sender:self]; 
} 

-(void) viewWillAppear:(BOOL)animated{ 
    [super viewWillAppear:animated]; 
    PFUser *currentUser = [PFUser currentUser]; 
    // crashes here when not currentUser: 
    NSLog(@"Logged user: %@ my_api_id=%@", currentUser.username, currentUser[@"api_id"]); 
} 

回答

0

文档不作任何在viewDidLoad执行赛格瑞时是否viewWillAppear:被调用的保证。这是您的代码不应该依赖的内部实现细节。