Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with presentViewController - no visible @interface for AppDelegate

I am making a splitview application for ipad and I need to display a different view controller for login purposes. I call this in the didFinishLaunchingWithOptions function in Appdelegate:

    LoginViewController *login = [[LoginViewController alloc] init];
[info setModalTransitionStyle: UIModalTransitionStyleCrossDissolve];
[self presentViewController:login animated:YES completion: nil];

but I get the error "No visible @interface for AppDelegate declares the selector presentViewController" on the third line.

The view controller I want to display is set to the LoginViewController class. I have Imported all classes.

I am pretty new to programming and would really appreciate any help!

Thanks!!

like image 410
Florian Ott Avatar asked Jul 11 '26 06:07

Florian Ott


1 Answers

What the error message says is that the class AppDelegate does not contain a method called presentViewController. Indeed, that method belongs to UIViewController class.

What you should do depends on how you created your project, whether it uses a navigation controller, a tab bar controller, or a simple view controller.

From your comment, I understand you used the Window-based template (or Empty application) to create your project. In this case, in your application:didFinishLaunching: you should have something like this:

self.login = [[LoginViewController alloc] init];
[self.window addSubview:self.login.view];

and also add to your AppDelegate.h the following declaration:

@property (nonatomic, strong) LoginViewController* login;

If this seems not to apply to your case, please, post your definition of application:didFinishLaunching:

like image 85
sergio Avatar answered Jul 14 '26 05:07

sergio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!