2016-08-24 7 views
0

다음 코드는 textview에 내부 이미지를 표시합니다. 외부 http : // 텍스트 뷰 링크를 표시하려고합니다.외부 이미지를 textview에 표시하는 방법은 무엇입니까?

다음 코드는 정상적으로 작동합니다. 외부 웹 링크 이미지를 표시하도록 도와주세요.

UITextField *txtstate =[[UITextField alloc]init]; [txtstate setFrame:CGRectMake(10, 30,170, 30)]; 
txtstate.delegate=self; 

NSString * quotStr03 = [[NSString alloc] initWithFormat:@"%@",[dict valueForKey:@"deal-image"]]; 
txtstate.text=quotStr03; 
txtstate.borderStyle = UITextBorderStyleLine; 
txtstate.background = [UIImage imageNamed:quotStr03]; 
[txtstate setAutocorrectionType:UITextAutocorrectionTypeNo]; 
[self.view addSubview:txtstate]; 
+0

가능한 중복 http://stackoverflow.com/questions/7694215/create-a-uiimage-a-url-in-ios) – rmaddy

답변

0
-(UIImage *) getImageFromURL:(NSURL*) imageURL 
{ 
    NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; 
    UIImage *image = [UIImage imageWithData:imageData]; 
    return image; 
} 

이 함수에 URL을 제공하여 외부 웹 링크 이미지를 얻을 것이다

([아이폰 OS의 URL과 함께있는 UIImage 만들기]의
+1

메인 스레드에서 이것을 절대하지 마십시오. – rmaddy

+0

당신은 맞습니다 rmaddy –

관련 문제