UIWebView - 1
来源:互联网 发布:windows 系统更新慢 编辑:程序博客网 时间:2024/06/04 23:19
UIWebview的使用和学习都不难,直接贴上来的一个例子,并且带有菊花的
#import "ViewController.h"#import "OpenUDID.h" //获取用户的OpenUDID#import "macaddress.h" //获取用户的macaddress#import <AdSupport/AdSupport.h>#define WAP_URL @"requested web address "@interface ViewController ()<UIWebViewDelegate>@property (nonatomic, strong) UIWebView* webView;@property (nonatomic, strong) NSString* mainUrl;@end@implementation ViewController- (void)viewDidLoad{ [super viewDidLoad]; // 添加加载画面 self.activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 48.0f, 48.0f)]; [_activityIndicator setCenter:self.view.center]; [_activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray]; [_activityIndicator setHidesWhenStopped:YES]; [_activityIndicator startAnimating]; // 添加WebView并加载WAP_URL NSString * platform = @"ios"; NSString * bundleid = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; NSString * version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; NSString * openudid = [OpenUDID value]; NSString * idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; NSString * macaddr = [MacAddress GetMacAddress]; NSString * idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; self.webView = [[UIWebView alloc] initWithFrame:self.view.frame]; self.mainUrl =[NSString stringWithFormat:WAP_URL, platform, bundleid, macaddr, idfa, idfv, openudid, version]; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.mainUrl] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:120.00]]; [self.webView setDelegate:self]; self.webView.hidden = YES; [self.view addSubview:_activityIndicator]; [self.view addSubview:self.webView];}// 更新app应用- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ NSString *urlStr = [[request URL] absoluteString]; //结合 itms协议,如果点击了协议之后页面立即返回主页,不然默认空白 if ([urlStr hasPrefix:@"itms-services"]) { [[UIApplication sharedApplication] openURL:[request URL]]; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.mainUrl] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:120.0]]; [self.view addSubview:self.webView]; return NO; } return YES;}# pragma mark - Web View Delegate// 数据加载完- (void)webViewDidFinishLoad:(UIWebView *)webView { [_activityIndicator stopAnimating]; webView.hidden = NO;}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; }@end
0 0
- UIWebView - 1
- Leaves and UIWebView (1)
- UIWebView小结--<1>
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebView
- UIWebview
- UIWebView
- UIWebView
- UIWebView
- NT的数字(被8整除)
- 老罗的“Android应用程序资源的编译和打包过程分析”一文的一点总结
- mysql 5.6 mysql 5.7修改root密码 密码过期
- 会操作excel就会批量证书打印!
- 完全背包 311
- UIWebView - 1
- java 中特殊字符
- struts2 action 使用心得 - 1
- 安卓源码--Launcher2去除两边阴影效果
- NYOJ-63-小猴子的下落
- java多线程以及java网络编程实现简单的聊天系统
- 同步函数
- android 属性学习
- Android读取word文件