将 UImage 传递给 UIImageView
我试图将从 UIImage 实例加载的图像传递到 DetailViewController 中的 UIImageView。我可以看到我正在成功拉取图像路径,并访问 .gif 文件,如 NSLogs () 中所示:
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
I am trying to pass an image loaded from a UIImage instance to a UIImageView in a DetailViewController. I can see I am getting pulling he image path successfully, and accessing the .gif file as seen in my NSLogs () :
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>
I am uncertain on how to pass this image to MapDetailsViewController
in the following method?
- (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;
}
I know I am doing something horribly wrong in this line :
MapDetailsViewController.selectedImageView.image = detailMap;
Since I get this error when I build:
Request for member 'image' in something not a structure or union
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更改
将MapDetailsViewController.selectedImageView.image =DetailMap;
为
dvController.selectedImageView.image=detailMap;
change
MapDetailsViewController.selectedImageView.image = detailMap;
to
dvController.selectedImageView.image = detailMap;
MapDetailsViewController.selectedImageView
应该是dvController.selectedImageView.image = detailMap;
。MapDetailsViewController.selectedImageView
should bedvController.selectedImageView.image = detailMap;
.