gpt4 book ai didi

ios - [UIImageView设置文本:]: unrecognized selector sent to instance

转载 作者:行者123 更新时间:2023-11-29 04:31:24 27 4
gpt4 key购买 nike

如果已经有人问过,我很抱歉,但问题来了:

当我快速滚动 tableView 时,我收到此消息:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIImageView setText:]:无法识别的选择器发送到实例 0x8a8f8d0”

这是我的代码:

   NewsVideoCell *cell = [tableView dequeueReusableCellWithIdentifier:AudioCellIdentifier];

if (cell == nil) {
cell = [[NewsVideoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AudioCellIdentifier];
}


cell.backgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];
cell.selectedBackgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];



UILabel *cellLabel = (UILabel *)[cell viewWithTag:1];
[cellLabel setText:[masjid objectForKey:@"name"]];

UILabel *cellDate = (UILabel *)[cell viewWithTag:2];
[cellDate setText:[[news objectAtIndex:indexPath.row] objectForKey:@"date"]];

UIImageView *cellImage = (UIImageView *)[cell viewWithTag:3];
NSString *imagePath = [masjid objectForKey:@"thumb"];
[cellImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@", imagePath]]];

UITextView *cellText = (UITextView *)[cell viewWithTag:5];
NSString *postText = [[news objectAtIndex:indexPath.row] objectForKey:@"title"];

[cellText setText:postText];

...

触发此异常的行是:

   [cellText setText:postText];

我发现这是由于过度保留或释放不足造成的,但我没有找到解决方法。

有什么帮助吗?

最佳答案

UITextView *cellText = (UITextView *)[cell viewWithTag:5];

在这行代码中,您的 UITextView 标签是“5”,我认为您可能为此 View 提供了不同的 ID。首先。

我遇到了类似的问题......我发现我的标签对于 TextView 和 Image View 是不同的。

how to Change TAG for a View ?

First select the View(ie UITextView) and than go to Attribute inspector Tab ..... Under the ' View ' you will find 'TAG' write there5.

关于ios - [UIImageView设置文本:]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11698030/

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