开发者

How to Load a View in viewDidLoad?

I want to load a second View at the beginning of a program. I thought, that the viewDidLoad-methode would be the right method. The problem is that it doesn't work.

The reason why I want to load a view in the viewDidLoad-method is that it is possible on a new device (iPad) to开发者_高级运维 load a view over the other view.

How can I make it? I tried this, but it doesn't work:

- (void)viewDidLoad {
    StartViewController * start = [[StartViewController alloc]initWithNibName:nil bundle:nil];
    start.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    start.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:start animated:YES];
}

I tried addSubview and it works, but then I don´t have the nice transition. Any idea? I also tried awakeFromNib. Also this is not a question about the iPad, so I don't break the nda. It is a general question, how to load a new view in the viewDidLoad-method (or an other method).


This works with viewDidAppear, not viewDidLoad. The view needs to have appeared for another to show up in front of it. Aside from that, I have the same code in some of my projects, does what you describe


Try to use the following code

- (void)viewDidLoad {
    [super viewDidLoad];
    //I mean after above line
    if(![self isLogin]) {
    //to login the user
    [self gotoCredentials];
    }
}

-(void)gotoCredentials  {
    Login *objLoginViewController=[[Login alloc] initWithNibName:@"Login" bundle:nil];        
    UINavigationController *objnavigationController = [[UINavigationController alloc] 
                                                       initWithRootViewController:objLoginViewController];       
    objnavigationController.modalPresentationStyle=UIModalPresentationFormSheet;
    [self  presentModalViewController:objnavigationController animated:YES];
    [objLoginViewController release];
    objLoginViewController=nil;
    [objnavigationController release];
    objnavigationController=nil;
}

the above code works fine for me

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜