一、网络
1、获取指定网址返回的字符串
Dim:
NSURL *url ;//目标网站的地址
NSURLRequest *request;//请求
NSData *response;//回复
NSString *str;//网站返回的字符串
request = [NSURLRequest requestWithURL:url];
response = [NSURLConnection
sendSynchronousRequest:request
jsonStr = [[NSString alloc]
2、从网上读取图片
Dim:
NSString *url;//目标图片的网址,带http://头
UIImage *img;//被取出来的图片对象
NSURL *imgUrl = [NSURL URLWithString:url];
NSData *imgData = [NSData dataWithContentsOfURL:imgUrl];
img = [UIImage imageWithData:imgData];
3、获取UiWebView正在访问的URL
在UIWebView所属的视图的控制器代码中实现委托
@interface tController : UIViewController
打开Interface Builder中对应视图,将UIWebView关联到FileOwner的delegate.
然后直接在tController.m文件中实现方法(不用在头文件中另外声明):
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithReque
NSURL *url = [request URL];
if (不允许浏览器继续访问该地址){
else{
return YES;}
}
4、加载本地网页
URLString = [[[NSBundle mainBundle]bundlePath]stringByAppendingPathCom
uiWebView loadUrl………………