收到错误 [NSCFString setBackgroundImage:forState:]:

发布于 2024-10-03 17:10:37 字数 1074 浏览 1 评论 0原文

我在将背景图像添加到表格视图单元格的内容时收到以下错误

 [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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-10-10 17:10:37

当您遇到内存管理问题时(选择器被发送到错误的实例是内存管理问题的迹象),您可以执行以下操作:

  1. 重新阅读 Cocoa 内存管理规则并确保您遵循它们。
  2. 运行静态分析器。这通常会发现您忽略内存管理规则的地方。
  3. 尝试使用 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:

  1. Re-read the Cocoa memory management rules and make sure that you're following them.
  2. Run the static analyser. This will often pick up places where you have neglected the memory management rules.
  3. Try using NSZombieEnabled to find out whether [and when] you are sending messages to unallocated instances.
绳情 2024-10-10 17:10:37

运行时说明了一切:您试图调用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文