0

次のコードは私のゲームのクラッシュを引き起こします..コメントアウトしても、まったく問題はありません..実際に間違いは見られません..最初はメモリの問題が原因ではないかと思っていましたが、 dealloc メソッド ビューと webview を解放しています。何が間違っていますか?

view = [[UIView alloc] initWithFrame:CGRectMake(0, self.boundingBox.size.width, self.boundingBox.size.width, self.boundingBox.size.height)];

         NSString *urlAddress=@"http://www.google.com";

         NSURL *url = [NSURL URLWithString:urlAddress];
         NSURLRequest *reqObject=[NSURLRequest requestWithURL:url];
         webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.boundingBox.size.width, self.boundingBox.size.height )];
         webView.delegate = self;
         [webView loadRequest:reqObject];
         [view addSubview:webView];

        UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [button setImage:[UIImage imageNamed:@"ok-button"] forState:UIControlStateNormal];

        [button addTarget:self
                   action:@selector(web)
         forControlEvents:UIControlEventTouchDown];
        [button setTitle:@"Show View" forState:UIControlStateNormal];
        button.frame = CGRectMake(self.boundingBox.size.width - 40, 10, 30, 30.0);
        [view addSubview:button];

         [[[CCDirector sharedDirector] openGLView] addSubview:view];
4

1 に答える 1

0

私はcocos2dゲームでUIWebviewを使用し、うまくいきました..ここに私のコードがあります:

        AppController *app =  (AppController*)[[UIApplication sharedApplication] delegate];

        self.infoWebView = [[UIWebView alloc] initWithFrame:webFrame];
        self.infoWebView.backgroundColor = [UIColor whiteColor];

        self.infoWebView.scalesPageToFit = YES;
        self.infoWebView.layer.cornerRadius = 15;
        self.infoWebView.layer.borderWidth = 5;
        self.infoWebView.layer.borderColor = [[UIColor whiteColor] CGColor];

        self.infoWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
        self.infoWebView.delegate = self;
        self.infoWebView.clipsToBounds = YES;

        [app.navController.view addSubview:self.infoWebView];

        [self.infoWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:GOODIES_HTML]]];
于 2013-01-24T08:28:10.363 に答える