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...
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:
- Re-read the Cocoa memory management rules and make sure that you're following them.
- Run the static analyser. This will often pick up places where you have neglected the memory management rules.
- Try using
NSZombieEnabled
to find out whether [and when] you are sending messages to unallocated instances.
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.
精彩评论