简体   繁体   English

HTML应用程序横向

[英]HTML app Landscape Orientation

I have searched for hours for the answer to my question and have found nothing that seems to work. 我已经搜寻了几个小时来寻找问题的答案,却没有发现任何可行的方法。 So please accept my apologies if this question has already been answered... 因此,如果这个问题已经得到回答,请接受我的歉意。

I am very new to app development and have been suggested to go down the route of html, css, jquery using XCODE and PhoneGap to build and compile. 我对应用程序开发非常陌生,建议使用XCODE和PhoneGap构建并编译html,css,jquery。 After a lot of faffing, I've managed to build a html page and test it through XCODE. 经过大量的忙碌之后,我设法建立了一个html页面并通过XCODE对其进行了测试。

My issue is I can not force the orientation to landscape. 我的问题是我不能强迫方向走向风景。

I found answers to set the orientation in the .plist file which I have done. 我在完成的.plist文件中找到了设置方向的答案。 This changes the orientation of toolbars and viewing window, but the content (HTML) stays in portrait mode. 这会更改工具栏和查看窗口的方向,但是内容(HTML)保持为纵向模式。

I found an example post where someone created a test app in landscape mode only, great I thought, but unfortunately this was in objective C. 我发现了一个示例帖子,其中有人只在横向模式下创建了一个测试应用程序,我想很好,但不幸的是,这是在目标C中。

For example this is in a file called ViewA.m 例如,这在一个名为ViewA.m的文件中

    // ViewA.m

#import "ViewA.h"

@implementation ViewA

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }

-(void)viewDidLoad
    {
//  self.view.frame = CGRectMake(0.0, 0.0, 1024.0, 768.0);
    [super viewDidLoad];
    }

@end

Do these separate files work for HTML as well as Objective C? 这些单独的文件是否适用于HTML和Objective C? Is there a jquery/javascript solution for html apps? 是否有适用于html应用程序的jquery / javascript解决方案?

I appreciate this is a bit of a "bitty" question and there could be multiple answers. 我知道这是一个“小问题”,可能会有多个答案。 I would appreciate any help or direction someone could offer. 有人可以提供任何帮助或指示,我将不胜感激。

If this has been solved already, as I say sorry for a repeat question, but there are so many of similar questions, it's very hard to get through them all! 如果已经解决了这个问题,正如我对一个重复的问题说的很抱歉,但是有很多类似的问题,很难一一解决!

Thanks in advance! 提前致谢!

I've noticed a few people have looked. 我注意到一些人已经看过了。 I've managed to find the answer to my question and wanted to post it, just incase anyone else is having a similar issue. 我设法找到了问题的答案,并希望将其发布,以防万一其他人遇到类似的问题。

To get the content of an app written in HTML to appear in landscape mode you need to go (in xcode) Folder (app name) -> Classes -> MainViewController.m 要获取以HTML编写的应用程序的内容以横向模式显示,您需要转到(以xcode表示)Folder(应用程序名称)->类-> MainViewController.m

You will see: 你会看见:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Change this to 更改为

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

And that should work :-) 那应该工作:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM