将 UImage 传递给 UIImageView

发布于 2024-10-16 18:54:49 字数 1311 浏览 0 评论 0原文

我试图将从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北恋 2024-10-23 18:54:49

更改

将MapDetailsViewController.selectedImageView.image =DetailMap;

dvController.selectedImageView.image=detailMap;

change

MapDetailsViewController.selectedImageView.image = detailMap;

to

dvController.selectedImageView.image = detailMap;

新雨望断虹 2024-10-23 18:54:49

MapDetailsViewController.selectedImageView 应该是 dvController.selectedImageView.image = detailMap;

MapDetailsViewController.selectedImageView should be dvController.selectedImageView.image = detailMap;.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文