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];  
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • cocos2d-x学习笔记(19)--label 、label atlas
  • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
  • Cocos2d-x学习(一):HelloWorld
  • cocos2dx在xcode下开发,编译到android上(2)
  • cocos2d 设置屏幕默认方向
  • Cocos2d-x 2.0 之 Actions “三板斧” 之一
  • cocos2d-x学习笔记(22)--地图的使用2(TMX) --Z-Order、AnchorPoi
  • cocos2d-x学习笔记(18)--游戏打包(windows平台)
  • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1