plist에서 이미지 파일에 대한 참조를 읽고 이미지를 상세보기로 표시하려고합니다. 내 테이블 뷰 레이아웃에서이 작업을 수행 할 수는 있지만, DetailViewController
nib 파일로이 작업을 수행하는 데 문제가 있습니다. 나는 누군가가 내가 문제를 해결하고 내가 잘못 가고있는 곳을 나에게 설명 할 수 있기를 바라고있다. 이 코드는 내가하고있는 일에 대한 나의 설명이다. 내가해야 할 일을 보여 주면서 내가 잘못하고있는 것을 나에게 설명 할 수 있다면, 정말로 고맙겠습니다. 나는 물건을 작동 시키려고 노력하는 것만큼 배우기 위해 노력하고 있습니다.plist 구문에서 이미지 이름을 읽으시겠습니까?
나는 두 곳에서 문제가 있다고 생각한다. 첫 번째는 내 didSelectRowAtIndexPath
방법 : //THIS IS WHERE I THINK THE PROBLEM IS
표시 위의 코드에서
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Get the dictionary of the selected data source.
NSDictionary *dictionary = [[[self.localSites objectAtIndex:indexPath.section]objectForKey:@"rowData"] objectAtIndex:indexPath.row];
TableDetailViewController *controller = [[TableDetailViewController alloc] initWithNibName:@"TableDetailViewController" bundle:[NSBundle mainBundle]];
controller.title = [dictionary objectForKey:@"Location"];
controller.dText = [dictionary objectForKey:@"details"];
// THIS IS WHERE THE PROBLEM IS
NSString *tiny = [dictionary objectForKey:@"thumb"];
controller.mainImage = [UIImage imageNamed:tiny];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
, 난 할 노력하고있어하면 PLIST에 문자열에 포함 된 이미지에 대한 참조를 잡고 이미지를 얻을 수있는 참조를 사용합니다. 이 접근 방식은 내 cellForRowAtIndexPath 메서드에서 잘 작동하며 테이블의 왼쪽면에 내 plist에서 참조 된 미리보기 이미지를 채 웁니다. 위의 코드 mainImage
에서
UIImageView
콘센트에 연결을 시도했습니다 문자열을 의미 내 아래 내
TableDetailViewController.m
파일을 통해
TableDetailViewController.xib
. 내가 문제 두 번째가 생각하는 곳은 다음과 같습니다
- (void)viewWillAppear:(BOOL)animated
{
[super viewDidLoad];
//This Bit says that the text contained in UITextView blurb is the string dText, which is used in my didSelectRowAtIndex method
blurb.text = dText;
//This is where I try to do the same thing by saying that UIImageView topImage is the NSString mainImage which I use in my didSelectRowAtIndex method
topImage.image = mainImage;
}
내 논리가 topImage가있는 UIImageView이라고했고 mainImage 내 didSelectRowAtIndex 방법에 내가 키 '엄지 손가락'의 값을 전달 이미지보기가 포함 된 문자열 포함 내 plist 파일에.
그러나 위의 경고를 throw합니다. 누구든지 도와 줄 수 있습니까?
시간을내어 읽어 주셔서 감사합니다.
당신은 그것을 어떻게 해결하는지 더 설명하고 싶습니까? 또는 코드 예제를 게시 하시겠습니까? – Albert
알버트, 코드는 위와 같습니다. NSString * mainImage를 작성하는 대신 TableDetailViewController.h 헤더 파일에서 UIIMage * mainImage를 작성합니다. 아래에서 설명하는 이유 때문에 간단합니다. 위의 나머지 코드는 정확합니다. –