Making one specific class of view controller auto rotate in a tab bar app, but forcing all other classes of view controller to stay portrait

前端 未结 1 1128
傲寒
傲寒 2021-01-21 07:36

I have a tab bar controller with this code

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


        
1条回答
  •  隐瞒了意图╮
    2021-01-21 08:10

    You could accomplish this by:

    1. setting statusBar orientation to viewWillAppear and viewWillDisappear

    -(void) viewWillAppear:(BOOL)animated { [super viewWillAppear: animated]; [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight]; }

    -(void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear: animated]; [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait]; }

    and rotating a view manually: self.view.transform = CGAffineTransformMakeRotation(M_PI/2);

    1. presenting that view modaly will trigger shouldAutorotateToInterfaceOrientation method

    0 讨论(0)
提交回复
热议问题