ある動作について困っています。
UIwebviewでローカルhtmlを呼び出したのだし、
そのローカルhtml内でゲームを動かすというような内容になっているのですが、
そのhtml内で読み込んでいるjavascriptが動かず、困っています。
UIwebviewはstoryboardで配置して、
ViewController.h
ViewController.m
で呼び出しています。
javascriptでは、addEventlistenerが動かず、困っております。
どうかご教授ください。
以下、サンプルソースになります。
■viewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
[tab=30]@property (weak, nonatomic) IBOutlet UIWebView *gameView;
@end
■viewController.m
@interface ViewController ()
@end
@implementation ViewController;
- (void)viewDidLoad
{
// [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGRect frame = [[UIScreen mainScreen] applicationFrame];
CGRect rect = CGRectMake(0,0,frame.size.width, frame.size.height);
UIWebView *wv = [[UIWebView alloc] initWithFrame:rect];
wv.scalesPageToFit = YES;
[self.view addSubview:wv];
NSString *path = [[NSBundle mainBundle] pathForResource:@"game" ofType:@"html"];
[wv loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
[super viewDidLoad];
}
document.addEventListener("touchstart",function(){
[tab=30]alert('aaa');
});
このような感じです、何かおかしな点があれば、ご指摘ください。
どうぞよろしくお願いします。