2 개의 URL이 xml 파일에서 전달되고 UITableView에서 상세보기로 전송되는 iphone 응용 프로그램을 만들고 있습니다. segue는 UIImageView에로드됩니다. 이 내 prepareForSegue 방법입니다 :Xcode iphone 프로그래밍 : URL 문자열을 segue를 통해 XML 파일에서 구문 분석하여 UIImageView에로드합니다.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"detail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSMutableString *imgURL1 = [feeds[indexPath.row] objectForKey: @"imageURL1"];
[[segue destinationViewController] setImg1:imgURL1];
//img1 is declared in the detailviewcontroller class
}
}
그리고 이것은 내 detailViewController에있는 viewDidLoad입니다 :
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL * imageURL1 = [NSURL URLWithString:self.img1];
NSData * imageData1 = [NSData dataWithContentsOfURL:imageURL1];
UIImage * imag1e = [UIImage imageWithData:imageData1];
appImage1.image = imag1e;
//appImage1 is also declared in the detailViewController class
}
이제 문제입니다 내가 아무것도 appImage1에 표시되지 않은 응용 프로그램없이 오류를 실행할 때 또는 버그가보고되었습니다. 당신의 도움에 대한 덕분에 여기
이'스토리 보드에서 설정 appImage1' 경우 : SEGUE 방법은 다음과 같습니다 있도록 XML 파서 내가했던 일은, 그래서 처음에 공백으로 url 변수에 URL을 저장했다가 stringByTrimmingCharactersInSet를 사용하는 것입니다? 실제로 설정 되었습니까? 또한 주 스레드에서'dataWithContentsOfURL'을 사용하는 것은 좋지 않습니다. – Wain
예 스토리 보드에서 설정됩니다 –
그리고 '피드'에 실제로 생각하는 내용과 생각하는 부분이 포함되어 있는지 확인하기 위해 디버깅했습니다. – Wain