cocos2d-x加载UIWebView显示网页(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-01 14:15 点击:次
p> //NSURL *url = [NSURL fileURLWithPath:filePath];//加载本地资源
p> NSURLRequest* request = [NSURLRequest requestWithURL:url];
p> [webview loadRequest:request];
p>
p> webview.delegate = self;
p>
p> [progress setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
p> //[progress startAnimating];
p> [progress setHidden:YES];
p>}
p>
p>- (void)viewDidUnload
p>{
p> [self setWebview:nil];
p> [self setBtn_back:nil];
p> [self setProgress:nil];
p> [self setBtn_reload:nil];
p> [self setBtn_back:nil];
p> [super viewDidUnload];
p> // Release any retained subviews of the main view.
p> // e.g. self.myOutlet = nil;
p>}
p>
p>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
p>{
p> // Return YES for supported orientations
p> return (interfaceOrientation == UIInterfaceOrientationPortrait);
p>}
p>
p>- (void)dealloc {
p> [webview release];
p> [btn_back release];
p> [progress release];
p> [btn_reload release];
p> [btn_back release];
p> [super dealloc];
p>}
p>- (IBAction)GoBack:(id)sender {
p> if ([webview canGoBack]) {
p> [webview goBack];
p> }
p> else
p> [self.view removeFromSuperview];
p>}
p>
p>-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
p>{
p> return YES;
p>}
p>-(void)webViewDidStartLoad:(UIWebView *)webView
p>{
p> [progress setHidden:NO];
p> [progress startAnimating];
p>}
p>-(void)webViewDidFinishLoad:(UIWebView *)webView
p>{
p> [progress stopAnimating];
p> [progress setHidden:YES];
p>}
p>-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
p>{
p> if ([error code] != -999 && error != NULL) { //error -999 happens when the user clicks on something before it's done loading.
p>
p> UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Error" message:@"Unable to load the page. Please keep network connection."delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil nil];
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>