cocos2d-x加载UIWebView显示网页
来源:未知 责任编辑:责任编辑 发表时间:2013-12-01 14:15 点击:次
2dx中点击按钮之后加载网页,在ios上用UIWebView来显示,实现回退和刷新当前界面。
p>2dx中调用方法
p>[cpp]
p>HelloWebView *webview = [[HelloWebView alloc]initWithNibName:nil bundle:nil];
p>[[UIApplication sharedApplication].keyWindow addSubview:[webview view]];
p>
p>用到的类
p>[objc]
p>//
p>// HelloWebView.h
p>// HelloTest
p>//
p>// Created by on 13-10-15.
p>// Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
p>//
p>
p>#import <UIKit/UIKit.h>
p>
p>@interface HelloWebView : UIViewController<UIWebViewDelegate>
p>@property (retain, nonatomic) IBOutlet UIWebView *webview;
p>@property (retain, nonatomic) IBOutlet UIBarButtonItem *btn_back;
p>
p>- (IBAction)GoBack:(id)sender;
p>@property (retain, nonatomic) IBOutlet UIActivityIndicatorView *progress;
p>@property (retain, nonatomic) IBOutlet UIBarButtonItem *btn_reload;
p>- (IBAction)ViewReload:(id)sender;
p>
p>@end
p>
p>[objc]
p>//
p>// HelloWebView.m
p>// HelloTest
p>//
p>// Created by on 13-10-15.
p>// Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
p>//
p>
p>#import "HelloWebView.h"
p>
p>@implementation HelloWebView
p>@synthesize progress;
p>@synthesize btn_reload;
p>@synthesize webview;
p>@synthesize btn_back;
p>
p>- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
p>{
p> self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
p> if (self) {
p> // Custom initialization
p> }
p> return self;
p>}
p>
p>- (void)didReceiveMemoryWarning
p>{
p> // Releases the view if it doesn't have a superview.
p> [super didReceiveMemoryWarning];
p>
p> // Release any cached data, images, etc that aren't in use.
p>}
p>
p>#pragma mark - View lifecycle
p>
p>- (void)viewDidLoad
p>{
p> [super viewDidLoad];
p> // Do any additional setup after loading the view from its nib.
p>
p> //设置属性
p> webview.scalesPageToFit = YES;//自动对页面精细鬼缩放以适应屏幕
p> //加载内容
p> NSURL* url = [NSURL URLWithString:@"http://www.baidu.com"];
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>