且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

允许一个视图支持多个方向,而其他人不要

更新时间:2023-12-01 10:53:16

您使用 presentModalViewController pushViewController 呈现的视图控制器应该支持任何方向,使用此方法:

The view's controller that you present either using presentModalViewController OR pushViewController should support any orientation, using this method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

使用这种方法,当您以横向显示控制器时,也以横向方向显示。

With this method, when you present your controller in landscape orientation, it will correctly appear in landscape orientation, too.