I am trying to make a custom login view popup like an alert view. I am simulating the alertview popup with the following function. This function is found in the viewDidload in mine loginViewController.m
-(void)initialDelayEnded {
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
self.view.alpha = 1.0;
[UIView animateWithDuration:1.0/1.5 animations:^{
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
}completion:^(BOOL complete){
[UIView animateWithDuration:1.0/2 animations:^{
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
}completion:^(BOOL complete){
[UIView animateWithDuration:1.0/2 animations:^{
self.view.transform = CGAffineTransformIdentity;
}];
}];
}];
}
- (void)viewDidLoad
{
[self initialDelayEnded];
[super viewDidLoad];
}
And I’m calling in my firstViewController my loginViewController in the following way.
LoginViewController *login = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:NULL];
[self presentViewController:login animated:YES completion:NULL];
But it crashes with the following error.
'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View <UIView: 0x8674bf0; frame = (0 20; 320 460); autoresize = W+H; layer = <CALayer: 0x8670620>> is associated with <LoginViewController: 0x868a7d0>. Clear this association before associating this view with <LoginViewController: 0x8451e70>.
Can somebody help me?
Thanks in advance !
Unless you have special reason, please keep
[super viewDidLoad];call to be done as early as possible within your local implementation. Meaning: call[self initialDelayEnded];AFTER[super viewDidLoad];Please make sure your .xib file named
LoginViewControllerhas only oneFile's OwnerinPlaceholdersand NO ViewController object inObjectspanels. And make sureFile's Owners custom class isLoginViewController. Can you please upload the screenshot of your .xib, specifically showingDocument Outline? It will be much easier to figure what could have been wrong