I'm trying to present a UITableView I've already made for users to put in data and save in parse. I'm pretty sure I don't present the navigation view.
When I log in, I get the error:
Checklists[4516:c07] Warning: Attempt to present <ChecklistsViewController: 0x10525e90>
on <UINavigationController: 0x9648270> while a presentation is in progress!
Thanks for your help.
#import "LoginViewController.h"
#import "ChecklistsViewController.h"
#import "SetupViewController.h"
#import <Parse/Parse.h>
@interface LoginViewController ()
@end
@implementation LoginViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
PFLogInViewController *login = [[PFLogInViewController alloc] init];
login.fields = PFLogInFieldsFacebook;
// Need to set the delegate to be this controller.
login.delegate = self;
login.signUpController.delegate = self; //signUpController is a property on the login view controller
[self presentModalViewController:login animated:NO];
}
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user
{
[self dismissModalViewControllerAnimated:YES];
NSLog(@"Successfully logged in.");
ChecklistsViewController *controller = [[ChecklistsViewController alloc] initWithStyle:UITableViewStylePlain];
controller.modalTransitionStyle = UITableViewStylePlain;
[self presentModalViewController:controller animated:YES];
}
This method has been deprecated for a good while
presentModalViewController:animated:
You should use this instead
presentViewController:animated:completion:
Same goes for this
dismissModalViewControllerAnimated:
Now we use this
dismissViewControllerAnimated:completion:
When we don't want a completion block, we just set it to nil.
But in your case, a completion block could fix your problem... it ensures a correct sequence of events, i.e. the presenting won't take place until the dismissing is complete.
- (void)logInViewController:(PFLogInViewController *)logInController
didLogInUser:(PFUser *)user
{
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"Successfully logged in.");
ChecklistsViewController *controller =
[[ChecklistsViewController alloc] initWithStyle:UITableViewStylePlain];
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:controller animated:YES completion:nil];
}];
}
[NB - modalTransitionStyle was incorrect in your original code, I have changed that also. Thanks to Daniel G for pointing this out]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With