iOS 怎样通过图片网址判断是不是空白图片
NSDictionary *dic = [self.dataArray objectAtIndex:[indexPath row]];//头像
NSString *headPath = [dic objectForKey:@"ownerimgurl"];
UIWebView *ownerHeadView = [[UIWebView alloc]initWithFrame:CGRectMake(10,10,60,60)];
ownerHeadView.scalesPageToFit=YES;
NSURL *headViewUrl = [NSURL URLWithString:headPath];
NSData *headData = [NSData dataWithContentsOfURL:headViewUrl];
UIImage *image = [UIImage imageWithData:headData];
if (image == nil) {
UIImageView *headView = [[UIImageView alloc]initWithFrame:CGRectMake(10,10,60,60)];
headView.image = [UIImage imageNamed:@"user_head_img"];
[cell.contentView addSubview:headView];
[headView release];
}
else {
NSURLRequest *requestHead = [NSURLRequest requestWithURL:headViewUrl];
[ownerHeadView loadRequest:requestHead];
[cell.contentView addSubview:ownerHeadView];
}
[ownerHeadView release];
ownerHeadView = nil;
为什么只走image == nil这一步 ios 图片 判断空白图片 --------------------编程问答-------------------- image不能这样判断吧?直接if(image),或者拿headData这个来判断试试 --------------------编程问答-------------------- 怎滴感觉代码这么熟悉…… --------------------编程问答-------------------- 通过网址取不到文件,那就是文件不存在或网络问题。
是不是空白图片,必须取下来然后找相应算法吧。
前后左右看看,LZ也许就在你身边,嘎嘎。 --------------------编程问答-------------------- 我的代码里有判断好不好,直接从svn下载最新的不就好了……
肯定是有人把我的demo泄漏了
补充:移动开发 , iPhone