开发者

Iphone load XIB/m/h Problem

why does this not work:

- (void)viewDidLoad {
Login *neu =[[Login alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:neu animated:NO];
}

b开发者_高级运维ut this works

-(IBAction)dologin:(id)sender{
Login *neu =[[Login alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:neu animated:NO];
}

I wanted to load a specified class directly when one is loaded,...


I think it will work if you move [self presentModalViewController:neu animated:NO]; to viewDidAppear:

That way the modal view controller will pop up as soon as the view appears.


viewDidLoad: isn't where you want to put up a modal view. It might be called after a low memory warning unloads your view controller, and then when the user navigates back to it, it will unexpectedly try to show a modal view. If you want to present something when the app launches, do so in applicationDidFinishLaunching: in your app delegate, or set up a NSNotfication observer:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidFinishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil];

and call presentModalViewController: there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜