开发者

Load mainView with shouldAutorotateToInterfaceOrientation

I am trying to load a view with the shouldAutorotateToInterfaceOrientation method, but I have a problem. When the device runs as landscape, I want to show the main view itself, and when when the devi开发者_JAVA技巧ce is portrait, load a custom UIView.

Here is my code:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations

        if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)|| (interfaceOrientation == UIInterfaceOrientationLandscapeRight))

            //doesn't show main view !!
            self.view;


        else if ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))

            //works fine ! 
            self.view = portraitView;


      return YES;

}


I figured out !!!! just call the view with modal on a method

- (void) mainView {
    screenTestViewController *mv = [[screenTestViewController alloc]initWithNibName:@"screenTestViewController" bundle:nil];
    [self presentModalViewController:mv animated:NO];

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    // Return YES for supported orientations 

    if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)|| (interfaceOrientation == UIInterfaceOrientationLandscapeRight))

        [self mainView];


.
.
.


You should push your custom UIView in: willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜