2012-01-17 79 views
0

我正在製作一個在縱向視圖中具有界面的iOS應用程序。不同視角的不同方向?

但是,當顯示網頁內容時,我希望以橫向格式顯示視圖,因爲我希望網站測試在最初顯示時不需要用戶縮放。

我可以告訴程序只在風景中呈現此視圖嗎?

謝謝。

回答

1

看起來像要強制定向到只有橫向模式..
我的繼承人在MyViewController.h
解決方案中添加此代碼對MyViewController的@interface之上

//force orientation on device 
    @interface UIDevice (PrivateOrientation) 
    - (void) setOrientation:(UIInterfaceOrientation)orientation; 
    @end 

然後在實現文件(MyViewController.m) 添加此代碼內viewWillAppear中:

//change orientation of device 
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft]; 

這將迫使設備取向landscap

//change orientation of device 
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; 

終於實現shouldAutorotateToInterfaceOrientation:給力的觀點爲風景模式留下E模式(或右取決於你想要什麼)
,如果你想回去肖像模式留下的ViewController在代碼里加入viewWillDisappear後離開或右(或兩者)

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

希望這有助於:3

+0

請問我的應用程序可以從App Store拒絕了呢? – DGund 2012-01-19 21:43:43

+0

我想你可能會發現這個主題有用[這裏](http://stackoverflow.com/questions/5030315/how-to-constrain-autorotation-to-a-single-orientation-for-some-views-while-allo )和[這裏](http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation) 我不能說它的100%可接受,根據什麼他們提到[這裏](http://stackoverflow.com/questions/7280464/device-orientation-change-in-legal-way-ios-4-0) >有沒有辦法強制設備方向,並得到您的應用程序由Apple批准。 – otakuProgrammer 2012-01-20 03:45:31

+0

我需要得到Apple批准,但謝謝。我會接受你的回答。 – DGund 2012-01-20 21:33:35

相關問題