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?

隨意留個言吧:)~

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料

標籤雲