Mac OS/WebView:为什么本地页面加载时Flash等插件不可用?
我们正在开发适用于 Mac 桌面的 Objective C 应用程序。
我们使用WebView组件来显示HTML页面。
从本地文件系统加载页面时,页面上不会显示 Flash 影片。 事实证明,问题并不完全在于 Flash。 大多数 WebView 插件都丢失了。
从互联网加载页面时,Flash 正常显示,并且有有很多可用的插件。
这个问题不会出现在我的 Mac 上,但它发生在我们 30% 的电脑上顾客。 它在 MacBook(不是 MacBook Air)上重现,Mac OS 版本为 10.5.8。
各位,请帮助我们,我不知道如何解决这个问题。 这是阻止我们发布产品的唯一障碍。
为什么本地页面加载时WebView插件不可用?
问题的根源是什么 - Safari 配置、Mac 安全设置、安装的某些软件?
如何在 Mac 上重现该问题?
这是我们用于本地页面加载的WebView初始化代码。
IBOutlet WebView* webView;
...
[[webView preferences] setPlugInsEnabled:YES];
WebFrame *mainFrame = [webView mainFrame];
NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
NSURL* url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request];
你注意到任何缺陷了吗?
更新1
UPDATE 2
最小测试,我只留下打开本地页面所需的代码。 没有显示诊断窗口。 测试应用程序,简单
简单测试的应用程序委托的完整源代码
#import "WebViewAppDelegate.h"
#import <WebKit/WebView.h>
#import <WebKit/WebFrame.h>
@implementation WebViewAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[webView preferences] setPlugInsEnabled:YES];
WebFrame *mainFrame = [webView mainFrame];
NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
NSURL* url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request];
}
@end
We are working on Objective C application for desktop Mac.
We use WebView component to display HTML pages.
When the page is loaded from the local file system, Flash movies are not displayed on the page.
As it turned out the problem is not exactly about Flash.
Most WebView plugins are missing.
When the page is loaded from the Internet, Flash is displayed properly and there are many plugins available.
The problem does not occur on my Mac, but it happens to 30% of our customers.
It is reproduced on MacBook (not MacBook air), Mac OS version is 10.5.8.
Guys, please help us, I have no idea how to tackle this.
This is the only obstacle preventing us from the product release.
Why WebView plugins are not available when a local page is loaded?
What can be the source of the problem - Safari configuration, Mac security settings, some software installed?
How can I reproduce the problem on my Mac?
This is our WebView initialization code for local page loading.
IBOutlet WebView* webView;
...
[[webView preferences] setPlugInsEnabled:YES];
WebFrame *mainFrame = [webView mainFrame];
NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
NSURL* url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request];
Have you noticed any flaws?
UPDATE 1
UPDATE 2
Minimal test, I have left only the code necessary to open the local page.
No diagnostic window displayed.
Test application, simple
Full source code for Application Delegate of the simple test
#import "WebViewAppDelegate.h"
#import <WebKit/WebView.h>
#import <WebKit/WebFrame.h>
@implementation WebViewAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[webView preferences] setPlugInsEnabled:YES];
WebFrame *mainFrame = [webView mainFrame];
NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
NSURL* url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request];
}
@end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的插件和警报可能会阻止您链接的js,螃蟹不会在您的网络视图中运行。
我可以通过指向包内容中的 html 文件来在另一个应用程序 webview 中运行 swf,并且没有启用任何“插件”。
您可以尝试将 WebKitDeveloperExtras booleen true 添加到您的首选项文件中,以便您可以使用 webinspector 检查。
your plugins and alert may be blocking your linked js, the crab does not run in your webview here.
I can run the swf in another apps webview by pointing to the html file in package contents and that's without any 'plugins' enabled.
you might try adding WebKitDeveloperExtras booleen true to your prefs file so you can check with webinspector.
好的,
从下载中运行 v2 失败,我仍然收到插件警报并且没有螃蟹,
所以我重建了 xcode 项目并包含 10.5 作为目标,然后手动将 html 和 swf 移动到内容中,它报告所有 safari 插件并运行10.5.8
所以虽然你的 plist 说 10.5 [min] 你的 sdk 目标是 10.6,所以它不会在 10.5
john上运行
ok,
running v2 from the download failed, I still got the plugins alert and no crab
so I rebuilt the xcode project and included 10.5 as a target, then manually moved the html and swf into contents and it reports all the safari plugins and runs on 10.5.8
so although your plist says 10.5 [min] your sdk target was/is 10.6, so it won't run on 10.5
john
我在 Google 'SketchUp' WebDialog 中运行它,Nib 文件具有与您完全相同的选项设置。如果您不熟悉 SU,它有一个可用的 Ruby 控制台,您可以向其中写入或提供 html 文件。只需要免费版本和一点红宝石即可。
约翰
I ran it in a Google 'SketchUp' WebDialog, the Nib file has the exact option settings as yours. If your unfamiliar with SU it has a Ruby Console available and you can write or serve html files to it. The free version and a little ruby is all that's required.
john