如何使用webview显示webgl URL

时间:2016-05-15 11:01:55

标签: objective-c uiwebview webgl

我想创建一个Web应用程序,它直接转到互联网上的WEBGL样本之一并在应用程序中显示。有人帮我吗?

1 个答案:

答案 0 :(得分:0)

找到了它。

   #import "WGLAppDelegate.h"

@implementation WGLAppDelegate

@synthesize window=_window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

//  Class ADWebView = NSClassFromString(@"ADWebView");
//  UIWebView* webView = (UIWebView *)[[[ADWebView alloc] initWithFrame:self.window.bounds] autorelease];
//  [webView setWebGLEnabled:YES];

 UIWebView* webView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)] autorelease];

id webDocumentView = [webView performSelector:@selector(_browserView)];
id backingWebView = [webDocumentView   performSelector:@selector(webView)];
[backingWebView _setWebGLEnabled:YES];

NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"alphatexture" ofType:@"html"];
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]];
[webView loadRequest:request];

UIViewController* viewController = [[[UIViewController alloc] init] autorelease];
viewController.view = webView;

self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];

return YES;
}

@end

您可以在此处找到示例应用:" https://github.com/atnan/UIWebViewWebGL"