开发者

modalViewController present when app opens

Hey im trying to display a modal view controller as soon as my tab bar controller app opens.

There is something wrong with the code below, and im 99% sure its the code for this. what do i put for the thing im calling it on?

[self presentModalViewController:promt animated:YES];

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

// Override point for customization af开发者_运维知识库ter app launch.


//Displays the password prompt modally 

PasswordPromViewController *promt = [[PasswordPromViewController alloc] initWithNibName:@"PasswordPromViewController" bundle:nil];
promt.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:promt animated:YES];
[promt release];






return YES;
}

any ideas would be helful! Cheers


I'm guessing you're adding this code in the application delegate file (eg if your app is called XXX then XXXAppDelegate.m). If this is the case you cannot use:

[self presentModalViewController:promt animated:YES];

as this method has to be called on an instance of a UIViewController. If you've set up your project in the standard way then your app delegate should have an object called window, which is a reference to the main window of the application. It's probably simplest if you add the modal view controller to that, like so:

[window presentModalViewController:promt animated:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜