2025-02-10

隻支持portait,不能旋轉:

-(BOOL)shouldAutorotate

{

    return NO;

}

支持旋轉:

-(BOOL)shouldAutorotate

{

    return YES;

}

-(NSUInteger)supportedInterfaceOrientations{

   

    return UIInterfaceOrientationMaskLandscape; //UIInterfaceOrientationMaskLandscape、UIInterfaceOrientationMaskAll、UIInterfaceOrientationMaskAllButUpsideDown

}

考慮到兼容低版本,最好加上:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

{

    return YES;

}

簡單說明:

UIInterfaceOrientationMaskLandscape  支持左右橫屏

UIInterfaceOrientationMaskAll  支持四個方向旋轉

UIInterfaceOrientationMaskAllButUpsideDown 支持除瞭UpsideDown以外的旋轉

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *