【问题标题】:Adding HTML file in xcode as UIWebView在 xcode 中添加 HTML 文件作为 UIWebView
【发布时间】:2011-11-04 05:07:19
【问题描述】:

当我在 UIWebView 中添加 HTML 文件时,我没有得到完整大小的图像。只有四分之一的图像正在显示。我的代码是

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
       [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Ganesh" ofType:@"html"]isDirectory:NO]]];
       webview.delegate=self;

} 图像显示为上下颠倒。谁能帮我解决这个问题?

【问题讨论】:

  • 你能展示你的示例html吗?
  • 在你的html文件中试试这个<head> <title></title> <meta name="viewport" content="width=device-width"/> </head>
  • 还是试过了....没有变化... :(
  • 你能分享你的示例html文件吗?

标签: iphone html xcode


【解决方案1】:
webView.backgroundColor=[UIColor colorWithRed:153.0/255 green:22.0/255 blue:11.0/255 alpha:1.0];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"faq-1" ofType:@"html"]isDirectory:NO ];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj]; 

【讨论】:

  • 这是您可以在 webView 上显示 .HTML 文件的方式,这里 faq-1 是 html 文件。
  • 感谢您的回复。但现在我只得到了一半的图像。从中间也断了。
  • 在 web 视图的 Xib 文件中有属性 Scaling :缩放页面以适应,选中此复选框并选中不透明,清除图形上下文,剪辑子视图,自动调整子视图,用户交互启用和多点触控那就试试吧。
  • 尝试了所有这些,然后图像显示在左上角。从中间折断,上下颠倒。
【解决方案2】:

根据orientation设置webview的框架。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-27
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    • 2012-02-21
    • 1970-01-01
    相关资源
    最近更新 更多