2016-05-30 22 views
3

我有一個在​​3210中被強制肖像的應用,但我希望應用中的特定視圖可以顯示爲橫向。什麼是實現這一目標的最佳方式? Ionic Framework內是否有選項?我如何強制使用Ionic Framework使景觀成爲特定視圖

我試圖設置視圖控制器通過CSS旋轉90deg的頁面容器元素,但這是一個不好的破解,因爲操作系統不知道該設備應該旋轉,因此狀態欄/操作系統導航項獲勝不會旋轉。

有沒有辦法在使用Ionic Framework時強制指定方向的特定視圖?

+0

好問題。但是,據我所知在Ionic框架中是不可能的,但如果有人知道解決方案,請糾正我。 – Nikola

回答

3

模擬人喜歡this插件幫助你。 對於景觀,你必須使用screen.lockOrientation('landscape');在控制器中。 而在其他頁面上,如果它們不是縱向視圖,則必須放置screen.lockOrientation('portrait');

0

for Ionic 2.x有離子原生插件可以使用。

import { ScreenOrientation } from '@ionic-native/screen-orientation'; 

constructor(private screenOrientation: ScreenOrientation) { } 

... 


// get current 
console.log(this.screenOrientation.type); // logs the current orientation, example: 'landscape' 

// set to landscape 
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); 

// allow user rotate 
this.screenOrientation.unlock(); 

// detect orientation changes 
this.screenOrientation.onChange().subscribe(
    () => { 
     console.log("Orientation Changed"); 
    } 
); 

參見here

相關問題