- (void)viewDidLoad {
[superviewDidLoad];
UIButton*btn = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
btn.frame=CGRectMake(100, 100, 80, 40);
[btnsetTitle:@"连接数据"forState:UIControlStateNormal];
[btnaddTarget:selfaction:@selector(pressBtn)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:btn];
// _data = [[NSMutableData alloc]init];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)pressBtn{
/**获取系统的UA */
UIWebView* webView = [[UIWebViewalloc]initWithFrame:CGRectZero];
NSString*userAgentString = [webViewstringByEvaluatingJavaScriptFromString:
@"navigator.userAgent"];
NSLog(@"useragent = %@",userAgentString);
}
此为获得当前模拟器或手机的UA的方法,写在viewDidLoad中便可
网友评论