Iphone 不同观点的不同取向?

Iphone 不同观点的不同取向?,iphone,ios,uiwebview,orientation,modalviewcontroller,Iphone,Ios,Uiwebview,Orientation,Modalviewcontroller,我正在制作一个iOS应用程序,它在纵向视图中有一个界面 但是,在显示web内容时,我希望视图以横向格式显示,因为我希望网站测试最初显示得更大,而用户无需缩放 我能告诉程序只在景观中呈现这个视图吗 谢谢。看起来您只想将方向强制为横向模式 这是我在MyViewController.h中的解决方案 将此代码添加到MyViewController的@界面上 //force orientation on device @interface UIDevice (PrivateOrientation

我正在制作一个iOS应用程序,它在纵向视图中有一个界面

但是,在显示web内容时,我希望视图以横向格式显示,因为我希望网站测试最初显示得更大,而用户无需缩放

我能告诉程序只在景观中呈现这个视图吗


谢谢。

看起来您只想将方向强制为横向模式
这是我在MyViewController.h中的解决方案
将此代码添加到MyViewController的@界面上

 //force orientation on device
    @interface UIDevice (PrivateOrientation)
    - (void) setOrientation:(UIInterfaceOrientation)orientation;
    @end
然后在实现文件(MyViewController.m)中 在视图中添加此代码将显示:

//change orientation of device
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
这将强制设备方向向左(或向右,具体取决于您的需要)
如果您想在离开viewcontroller后返回到纵向模式,则在viewcontroller中添加此代码将消失:

//change orientation of device
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
最后实现shouldAutorotateToInterfaceOrientation:强制视图进入横向模式左侧或右侧(或两者)


希望这有帮助:3

我的应用程序会因此被应用程序商店拒绝吗?我想你可能会发现这个话题很有帮助,而且我不能说它100%可以接受,基于他们提到的内容>没有办法强制设备定向并让你的应用程序获得苹果的批准。我需要让苹果批准它,但谢谢。我接受你的回答。
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}