[iOS] performSegueWithIdentifier in viewDidLoad

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

 

이렇게 하면

Warning: Attempt to present <GoogleMapViewController: 0x8b40990> on <ViewController: 0x8b3b8e0> whose view is not in the window hierarchy!

라고 에러가 뜨고, 아무 동작도 하지 않는다.

 

- (void)viewDidLoad
{
    [super viewDidLoad];
	[self performSelector:@selector(loadNextViewController) withObject:nil afterDelay:0];
}

-(void)loadNextViewController
{
	[self performSegueWithIdentifier:@"google" sender:self];
}

이런 식으로 호출하면 된다.

 

도움받은 곳 : http://stackoverflow.com/questions/15607821/manual-modal-segue-does-not-work-view-controller-is-not-in-the-window-hierarchy