2016-05-15 55 views
0

我想创建一个web应用程序,直接转到互联网上的WEBGL示例之一,并将其​​显示在应用程序中。任何人都可以帮助我吗?如何使用webview显示webgl URL

+0

更多contenxt请... –

+0

我尝试让使用一个UIWebView。而该应用程序视图中的简单的应用程序应该显示的内容一个网址,它是webgl样本的地址。 –

回答

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