收到错误 [NSCFString setBackgroundImage:forState:]:
我在将背景图像添加到表格视图单元格的内容时收到以下错误
[NSCFString setBackgroundImage:forState:]: unrecognized selector sent to instance
UIButton *playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
playBtn.frame = CGRectMake(x+playBtnXPos, y+playBtnYPos, playBtnWidth, playBtnHeight);
[playBtn addTarget:self action:@selector(playBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
if(playingButton && streamer){
if(playingButtonTag == i && [streamer isPlaying]){
[playBtn setBackgroundImage:[UIImage imageNamed:pauseBtnimgName] forState:UIControlStateNormal];
playingButton = playBtn;
}else [playBtn setBackgroundImage:[UIImage imageNamed:playBtnimgName] forState:UIControlStateNormal];
}else [playBtn setBackgroundImage:[UIImage imageNamed:playBtnimgName] forState:UIControlStateNormal];
playBtn.tag = i;
[cell.contentView addSubview:playBtn];
.....
任何人都可以帮助我...
谢谢...
i am getting the following error while adding the background image to the content of a table view cell
[NSCFString setBackgroundImage:forState:]: unrecognized selector sent to instance
UIButton *playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
playBtn.frame = CGRectMake(x+playBtnXPos, y+playBtnYPos, playBtnWidth, playBtnHeight);
[playBtn addTarget:self action:@selector(playBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
if(playingButton && streamer){
if(playingButtonTag == i && [streamer isPlaying]){
[playBtn setBackgroundImage:[UIImage imageNamed:pauseBtnimgName] forState:UIControlStateNormal];
playingButton = playBtn;
}else [playBtn setBackgroundImage:[UIImage imageNamed:playBtnimgName] forState:UIControlStateNormal];
}else [playBtn setBackgroundImage:[UIImage imageNamed:playBtnimgName] forState:UIControlStateNormal];
playBtn.tag = i;
[cell.contentView addSubview:playBtn];
.....
can anybody help me out...
thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您遇到内存管理问题时(选择器被发送到错误的实例是内存管理问题的迹象),您可以执行以下操作:
NSZombieEnabled
来了解您是否[以及何时]向未分配的实例发送消息。When you have memory management issues (selectors being sent to the wrong instances is a sign of memory management issues), there are a number of things you can do:
NSZombieEnabled
to find out whether [and when] you are sending messages to unallocated instances.运行时说明了一切:您试图调用
NSString
中不存在的东西,并且我确信[NSCFString setBackgroundImage:forState:]
确实存在不存在,因此会出现错误并“可能”崩溃。编译器应该在源代码中出现错误的地方向您显示警告。The runtime is saying it all: You're trying to call something in
NSString
that doesn't exist, and I know for sure that[NSCFString setBackgroundImage:forState:]
does not exist, hence the error and "possibly" a crash. The compiler should show you a warning in your source code where you're going wrong.