gpt4 book ai didi

ios - 未设置 UIImageView 图像

转载 作者:行者123 更新时间:2023-11-29 12:59:52 24 4
gpt4 key购买 nike

我有一个 TableView,其中包含从名为 arryData 的 NSArray 中获取的单元格文本的名称列表。在 didSelectRowAtIndexPath 中,我有:

NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil];
[self.navigationController pushViewController:nextController animated:YES];
[nextController changeProductText:[arryData objectAtIndex:indexPath.row]];

在 NextViewController 中我有:

- (IBAction) changeProductText:(NSString *)str{
NSLog(@"whosthere%@", str);
self.title = str;
if ( [str isEqualToString: @"Row 1 Name"]) {
lblProductTxt.image = [UIImage imageNamed:@"row1name.png"];
job.text = @"Sr. Minister & Elder";
NSLog(@"Row 1 Name");
emailaddress = @"Row1Email@att.net";
}
...
}

当我单击第 1 行名称时,我的控制台显示“whosthererow1name”,另一个 NSLog 触发第 1 行名称,但是图像和文本都没有显示。我使用 IB 和 XIB 文件构建了这个。我确保类匹配并且 UILabel 和 UIImageView 的 IBOutlet 已连接。他们是。

为什么这不起作用?

更新:
刚刚在 6.1 设备和 7.0 设备上对此进行了测试。 6.1 正常,7.0 不显示图像。

最佳答案

这不起作用的原因是标签和 ImageView 在您调用 changeProductText: 时将为空,因为 nextController 的 View 尚未加载。我不明白的是为什么它在 iOS 6 中工作。你确定你在 iOS 6 中正是这样做的吗?这样做的方法是将一个字符串(以及您想要的任何其他内容)传递给您在 nextController 中创建的属性,并在 viewDidLoad 中填充 UI 元素。

关于ios - 未设置 UIImageView 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20060780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com