开发者

Load mainView with shouldAutorotateToInterfaceOrientation

开发者 https://www.devze.com 2023-01-31 08:19 出处:网络
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开

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

精彩评论

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