image-url-string이 올바른 URL을 제공하는지 어떻게 확인할 수 있습니까? 이 URL에 대해 이야기하고 있습니다. http://rscagen3t004-dev.tdlinx.dev/sites/all/themes/rsca/resources/images/RSCA_logo.pngURL 문자열이 올바른 웹 페이지를 제공하는지 확인하십시오.
웹 페이지를 사용할 수없는 링크를 클릭하면 볼 수 있습니다.
if([meta.met_thumb hasPrefix:@"http://"]){
imgURL = meta.met_thumb;
NSData *walImage = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imgURL]];
NSLog(@"walImage is %@",walImage);
float newHeight2;
if (walImage != nil) {
UIImage *imgIcon = [UIImage imageWithData:walImage];
if (imgIcon != nil) {
float width = imgIcon.size.width;
float heigt = imgIcon.size.height;
if(heigt < 240){
float newWidth = (heigt/240);
float newWidht2 = (newWidth/ width);
//[imgNews setFrame:CGRectMake(40,y, newWidht2,heigt)];
}
float newHeight = (width/240);
newHeight2 = heigt/ newHeight;
}else{
newHeight2 = 240;
}
}else{
newHeight2 = 240;
}
height = [self heightForStatus:attString] + y + newHeight2 + 70;
}else{
height = [self heightForStatus:attString] + y + 240 + 70;
}
을하지만 그것은 [[NSData alloc] init]
의 라인을 실행하는 데 시간이 오래 걸리는 : 순간 나는 내 코드에서이 일을하고 있습니다.
아무도 도와 줄 수 있습니까?
미리 감사드립니다.
"유효한 URL"이란 무엇입니까? 코드에서 URL이 유효한지 테스트하지 않고 이미지를 다운로드하십시오. –
링크를 클릭하면보실 수 있습니다. "웹 페이지를 사용할 수 없습니다."라는 메시지가 다시 표시되지 않습니다. – Steaphann
"유효한"URL은 서버가 응답하거나 응답이 빠름을 의미하지 않습니다. 코드를 배경으로 두십시오. –