在 UIWebView 上显示背景图像

2023-10-22移动开发问题
2

本文介绍了在 UIWebView 上显示背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试构建一个原生应用程序,该应用程序的所有意图和目的都是 HTML/CSS 和 Javascript.一切正常,但是当 UIWebView 加载时,在填充 DOM、检索图像等时会有延迟.

I'm trying to build a native application that for all intents and purposes is HTML/CSS and Javascript. It all works fine, but when the UIWebView loads there's a delay while the DOM is populated, images retrieved etc.

到底有没有在 UIWebView 上显示背景图像,或者它背后的东西?理想情况下,这将与初始屏幕相同,因此不会影响从斜线过渡到应用的体验.

Is there anyway to display a background image on the UIWebView, or something behind it? Ideally this will be the same as the splash screen so it doesn't affect the experience of transitioning from slash to app.

谢谢

罗比

推荐答案

我不相信你想将 UIWebView 设置为透明并在其后面显示图像.

I don't believe you want to be setting the UIWebView as transparent and showing an image behind it.

相反,在 UIWebView 加载其内容之前,您应该有某种视图(可能带有您建议的图片,可能带有 UIIndicator 和使页面变暗"的半透明视图).

Instead you should have some sort of view (maybe with a picture as you suggest, maybe with a UIIndicator and a semi-transparent view that "darkens" the page) that sits there until the UIWebView has loaded its content.

为此,首先你的类应该订阅 UIWebViewDelegate 协议:

To do this, first your class should subscribe to the UIWebViewDelegate protocol:

@interface myWebView : UIViewController <UIWebViewDelegate> {
  // variables etc
}

然后,您可以在加载时显示视图:

Then, you can show a view on load:

-(void)viewDidLoad {
  myView.hidden = NO;
}

最后,您可以覆盖 webViewDidFinishLoad 方法以在加载后将其隐藏

And finally, you can override the webViewDidFinishLoad method to hide it once it's loaded

- (void)webViewDidFinishLoad:(UIWebView *)localwebView {
    myView.hidden = YES;
}

这篇关于在 UIWebView 上显示背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7