Just My Life & My Work

播放影片時特定畫面橫向文章提到播放影片時要橫向,那麼在播放完影片後,想要回復到直向可以怎麼做?

[iOS] 播放影片時特定畫面橫向

原來只要一行程式碼就能搞定!

/**
 Theme: Force to Rotate Portrait
 IDE: Xcode 9
 Language: Objective C
 Date: 107/01/02
 Author: HappyMan
 Blog: https://cg2010studio.com/
 */

[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationPortrait) forKey:@"orientation"];

注意字串orientation

可使用方向的列舉:

typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {

    UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown,

    UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,

    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,

    UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,

    UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft

} __TVOS_PROHIBITED;

參考:How to force view controller orientation in iOS 8?

廣告

隨意留個言吧:)~

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com 標誌

您的留言將使用 WordPress.com 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 /  變更 )

連結到 %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

標籤雲

%d 位部落客按了讚: