ios – 使用自定义表格单元格时“无法识别的选择器发送到实例”

ios – 使用自定义表格单元格时“无法识别的选择器发送到实例”,第1张

概述我已经实现了一个自定义表格单元格,并在表格进入cellForRowAtIndexPath时收到运行时错误(“无法识别的选择器发送到实例”).尝试实例化自定义单元格时发生错误.我之前已经成功实现了这一目标,但现在错误不会消失.我有一个prtotype单元格,其自定义类属性设置为自定义单元格UITableViewCell子类.这是自定义单元格: #import "FavoriteCell.h"@i 我已经实现了一个自定义表格单元格,并在表格进入cellForRowAtIndexPath时收到运行时错误(“无法识别的选择器发送到实例”).尝试实例化自定义单元格时发生错误.我之前已经成功实现了这一目标,但现在错误不会消失.我有一个prtotype单元格,其自定义类属性设置为自定义单元格UItableVIEwCell子类.这是自定义单元格:
#import "FavoriteCell.h"@implementation FavoriteCell@synthesize lblGaugeID,lblMainTitle,bgImage;- (ID)initWithStyle:(UItableVIEwCellStyle)style reuseIDentifIEr:(Nsstring *)reuseIDentifIEr{    bgImage = [UIImage imagenamed:@"tableCellBG.png"];    self = [super initWithStyle:style reuseIDentifIEr:reuseIDentifIEr];    if (self) {        UIcolor *transparentBG = [UIcolor colorWithRed:0.0 green:0.0 blue:0.0 Alpha:0.0];        UIcolor *foregroundcolor = [UIcolor colorWithRed:1.0 green:1.0 blue:1.0 Alpha:1.0];        //UIcolor *shadowColot = [UIcolor colorWithWhite:0.75 Alpha:1.0];        CGSize size = self.contentVIEw.frame.size;        self.backgroundVIEw = [[UIImageVIEw alloc] initWithImage:bgImage];        self.lblMainTitle = [[UILabel alloc] initWithFrame:CGRectMake(8.0,0.5,size.wIDth-16,size.height-40)];        [self.lblMainTitle setFont:[UIFont systemFontOfSize:12.0]];        [self.lblMainTitle setTextAlignment:NSTextAlignmentleft];        [self.lblMainTitle setautoresizingMask:(UIVIEwautoresizingFlexibleWIDth | UIVIEwautoresizingFlexibleHeight)];        [self.lblMainTitle setBackgroundcolor:transparentBG];        self.lblGaugeID = [[UILabel alloc] initWithFrame:CGRectMake(20.0,31.0,size.height-40)];        [self.lblGaugeID setFont:[UIFont boldSystemFontOfSize:15.0]];        [self.lblGaugeID setTextAlignment:NSTextAlignmentleft];        [self.lblGaugeID setTextcolor:foregroundcolor];        [self.lblGaugeID setShadowOffset:CGSizeMake(0.2,0.2)];        [self.lblGaugeID setautoresizingMask:(UIVIEwautoresizingFlexibleWIDth | UIVIEwautoresizingFlexibleHeight)];        [self.lblGaugeID setBackgroundcolor:transparentBG];        [self.contentVIEw addSubvIEw:lblGaugeID];        [self.contentVIEw addSubvIEw:lblMainTitle];    }    return self;}@end

这里是它的实例(摘自我的视图控制器类):

-(FavoriteCell*)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{    Nsstring *cellIDentifIEr = @"favoriteCell";    FavoriteCell *cell = (FavoriteCell*)[tableVIEw dequeueReusableCellWithIDentifIEr:cellIDentifIEr]; //error    if(cell == nil){        cell = [[FavoriteCell alloc] initWithStyle:UItableVIEwCellStyleDefault reuseIDentifIEr:cellIDentifIEr];    }    Nsstring *sitename = [faveKeys objectAtIndex:indexPath.row];    [cell.lblMainTitle setText:sitename];    [cell.lblGaugeID setText:[allFavorites objectForKey:sitename]];    return cell;}

这是完整的错误消息:

@H_502_10@

* Terminating app due to uncaught exception ‘NSinvalidargumentexception’,reason: ‘-[__NSCFConstantString instantiateWithOwner:options:]: unrecognized selector sent to instance 0x24bb0’

谁能提供一些关于检查的建议?谢谢!维维安

解决方法 使用 – (voID)registerNib:(UINib *)nib forCellReuseIDentifIEr 总结

以上是内存溢出为你收集整理的ios – 使用自定义表格单元格时“无法识别的选择器发送到实例”全部内容,希望文章能够帮你解决ios – 使用自定义表格单元格时“无法识别的选择器发送到实例”所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1109542.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存