gpt4 book ai didi

ios - UITableViewCell - 发送到实例的无法识别的选择器

转载 作者:行者123 更新时间:2023-11-28 21:40:08 28 4
gpt4 key购买 nike

我正在尝试向左滑动,但出现此错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [UITableViewCell setDelegate]: unrecognized selector sent to instance 0x7fbadb85d710'

这行错误:

cell.delegate = self;
cell.allowsMultipleSwipe = allowMultipleSwipe;
cell.rightSwipeSettings.transition = data.transition;
cell.rightExpansion.buttonIndex = data.rightExpandableIndex;
cell.rightExpansion.fillOnTrigger = YES;
cell.rightButtons = [self createRightButtons:data.rightButtonsCount];

我的代码:

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MGSwipeTableCell *cell ;
static NSString * reuseIdentifier = @"listAlbuns";
cell = [self.tblAlbum dequeueReusableCellWithIdentifier:reuseIdentifier];
if (!cell) {
cell = [[MGSwipeTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
}

NSString *sectionTitle = [albumSectionTitles objectAtIndex:indexPath.section];
NSMutableDictionary *sectionAlbuns = [albuns objectForKey:sectionTitle];
NSString *title = [sectionAlbuns objectForKey: [NSString stringWithFormat:@"%i", indexPath.row]];
NSMutableDictionary *album = [baseController getCurrentItemByTitle: albunsBD :title];

TestData *data = [tests objectAtIndex:indexPath.row];
NSInteger ID = [album objectForKey: @"1"];
cell.textLabel.text = [album objectForKey: @"2"];
cell.detailTextLabel.text = [[albumDAO selectArtistByAlbumID: ID] uppercaseString];
cell.imageView.image = [UIImage imageNamed: @"icones-categorias-album"];
cell.imageView.image = [albumDAO getThumb: ID];

cell.tag = [album objectForKey: @"1"];
cell.delegate = self;
cell.allowsMultipleSwipe = allowMultipleSwipe;
cell.rightSwipeSettings.transition = data.transition;
cell.rightExpansion.buttonIndex = data.rightExpandableIndex;
cell.rightExpansion.fillOnTrigger = YES;
cell.rightButtons = [self createRightButtons:data.rightButtonsCount];

return cell;
}

有人知道可以是什么吗?

最佳答案

由于您正在尝试使用 UITableViewCell子类,MGSwipeTableViewCell ,您必须确保您从 dequeueReusableCellWithIdentifier 取回的单元格返回 MGSwipeTableViewCell .

首先,您可以删除 if (!cell) { ... } block ,如 dequeueReusableCellWithIdentifier应该返回 UITableViewCell如果您在 .xib 或 Storyboard上设置了标识符。如果单元格在 Storyboard或 .xib 上没有重用标识符,则拥有额外的 block 会使此代码更难调试。

接下来,在您尝试出队的单元格所在的 .xib 或 Storyboard中,选择原型(prototype) UITableViewCell并查看“自定义类”部分下名为“类”的框。将其更改为 MGSwipeTableViewCell ,我怀疑它设置为 UITableViewCell .这应该可以解决问题。这是我正在谈论的 Xcode 中的区域:

custom class

您应该能够设置 cell.delegate 和其他 MGSwipeTableViewCell出队后的属性 MGSwipeTableViewCell .

关于ios - UITableViewCell - 发送到实例的无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32480083/

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