从UISlider实现valueChanged操作时出现无法识别的选择器错误 [英] Unrecognized selector error when implementing a valueChanged action from a UISlider

查看:48
本文介绍了从UISlider实现valueChanged操作时出现无法识别的选择器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的 UIViewController 子类:

I have a very simple subclass of UIViewController:

@interface RoastChickenViewController : UIViewController {
    IBOutlet UISlider *weightSlider;    
}

@property (nonatomic,retain) UILabel *cookingTimeLabel;
- (void) weightValueHasChanged:(id)sender;
@end

我的xib文件被设置为具有 RoastChickenViewController ,因为它是文件的所有者类型,并且已连接 weightSlider 并将'valueChanged'操作连接到 weightValuHasChanged:.

My xib file is set to have a RoastChickenViewController as it's File's owner type and the weightSlider is connected and the 'valueChanged' action is connected to weightValuHasChanged:.

问题一出,当我触摸滑块(模拟器或设备)时就会得到:

Trouble is as soon as I touch the slider (simulator or device) I get:

2010-08-21 20:26:07.688 CookIt1[26682:207] -[NSCFString weightValueHasChanged:]: unrecognized selector sent to instance 0x59215e0
2010-08-21 20:26:07.690 CookIt1[26682:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString weightValueHasChanged:]: unrecognized selector sent to instance 0x59215e0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x02395919 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x024e35de objc_exception_throw + 47
    2   CoreFoundation                      0x0239742b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x02307116 ___forwarding___ + 966
    4   CoreFoundation                      0x02306cd2 _CF_forwarding_prep_0 + 50
    5   UIKit                               0x002b9e14 -[UIApplication sendAction:to:from:forEvent:] + 119
    6   UIKit                               0x003436c8 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x00345b4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    8   UIKit                               0x003c23ac -[UISlider beginTrackingWithTouch:withEvent:] + 731

历史的一点点,我实际上是通过直接继承UIView来完成这项工作的.我已经设法将其从UIView转换为UIViewController了,我想这是实现这种简单行为的更自然的方法.

A little bit of history, I actually had this working using having subclassed UIView directly. I have managed to break it on converting in from a UIView to a UIViewController, which I guess is the more natural way to implement simple behavior like this.

是否存在某种我可以申请的检查清单,因为显然我缺少某些东西.

Is there some sort of check list I can apply as there is obviously something I'm missing.

推荐答案

这种错误(当接收消息的对象与预期的类型完全不同时)通常是由于某种原因取消了接收者对象及其地址而发生的现在内存中的内存已被其他一些对象占用.

This kind of error (when object that receives a message is of completely different type from expected) often occurs when the receiver object for some reason was deallocated and its address in memory now is occupied with some other object.

因此,您需要检查控制器的内存管理是否一切正常.

So you need to check if everything correct with memory management of your controller.

这篇关于从UISlider实现valueChanged操作时出现无法识别的选择器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆