所以我已经开发的应用,我有所有工作funntcions,但我已经在角落里做了一个按钮,使用此命令一个按钮来打开一个URL
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com/"]]];
,当我点击按钮,没有任何发生。 我想让按钮加载一页:) 请帮忙,谢谢! :)
所以我已经开发的应用,我有所有工作funntcions,但我已经在角落里做了一个按钮,使用此命令一个按钮来打开一个URL
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com/"]]];
,当我点击按钮,没有任何发生。 我想让按钮加载一页:) 请帮忙,谢谢! :)
使用,如果你想在Safari
NSString *urlstring = [NSString stringWithFormat:@"http://www.google.com/"];
NSURL *url = [NSURL URLWithString:urlstring];
NSLog(@"url = %@",url);
[[UIApplication sharedApplication] openURL:url];
打开一个网站或者,如果你想在一个UIWebView打开一个网站
NSString *[email protected]"http://www.google.com";
NSURL *nsurl=[NSURL URLWithString:url];
NSLog(@"url = %@",nsurl);
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
也可使用此代码,这个代码,请确定你已经正确连接了你的Outlets。
哪里是webView?它是否已经在当前的视图控制器上? – Kal
是的,但我想做一个按钮,将带我到一个URL,我做的按钮,我只需要代码,所以当我点击按钮的URL请求,并打开.. – ModH4ck
我猜你没有连接WebView你的出口叫做webView。 –