将UImage传递给UIImageView

时间:2011-02-09 15:59:45

标签: iphone objective-c uiviewcontroller uiimageview uiimage

我正在尝试将从UIImage实例加载的图像传递给DetailViewController中的UIImageView。我可以看到我成功地拉动了他的图像路径,并访问了我的NSLogs()中看到的.gif文件:

2011-02-09 10:52:13.404 WorldGovernments[31443:207] pathToMap = af-map.gif
2011-02-09 10:52:13.406 WorldGovernments[31443:207] detail map is: <UIImage: 0x4e44a80>

我不确定如何在以下方法中将此图像传递给MapDetailsViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

MapDetailsViewController *dvController = [[MapDetailsViewController alloc] initWithNibName:@"MapDetailsView" bundle:[NSBundle mainBundle]];

NSDictionary* tempDict=[sortedCountries objectAtIndex:indexPath.row];

NSString *pathToMap = [tempDict objectForKey:@"map"];

NSLog(@"pathToMap = %@",pathToMap);

UIImage *detailMap = [UIImage imageNamed:pathToMap];

NSLog(@"detail map is: %@",detailMap);

MapDetailsViewController.selectedImageView.image = detailMap;

[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
//dvController = nil;


}

我知道我在这方面做了一些可怕的错误:

MapDetailsViewController.selectedImageView.image = detailMap;

因为我在构建时遇到此错误:

Request for member 'image' in something not a structure or union

2 个答案:

答案 0 :(得分:3)

更改

MapDetailsViewController.selectedImageView.image = detailMap;

dvController.selectedImageView.image = detailMap;

答案 1 :(得分:2)

MapDetailsViewController.selectedImageView应为dvController.selectedImageView.image = detailMap;