开发者

multi viewcontrollers and rotation

开发者 https://www.devze.com 2023-01-19 08:39 出处:网络
I hope to rotate only one viewcontroller in a multi viewcontroller ( rootviewcontroller and viewcontroller 1, viewcontroller2,..)project开发者_Go百科.

I hope to rotate only one viewcontroller in a multi viewcontroller ( rootviewcontroller and viewcontroller 1, viewcontroller2,..)project开发者_Go百科.

Is it possible?

I noticed I have to make rootviewcontroller enable shouldAutorotateToInterfaceOrientation.

But the function willAnimateRotationToInterfaceOrientation in the viewcontroller that I prefer to rotate was not fired.


If you have sub controllers like :

RootViewController FirstViewController SecondViewController ...

When willAnimateRotationToInterfaceOrientation of RootViewController is called, you need to called yourself the same function of FirstViewController, SecondViewController etc.

For example

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

  [ FirstViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration ];
  [ SecondViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration ];

}

By the way, yes you need to implement shouldAutorotateToInterfaceOrientation to say if YES or NO the controller should rotate.

Good Luck !

0

精彩评论

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