2012-01-17 40 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

相关问题