Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone [UIView setText:]:发送到实例0x89625d0的选择器无法识别_Iphone_Ios_Uiview - Fatal编程技术网

Iphone [UIView setText:]:发送到实例0x89625d0的选择器无法识别

Iphone [UIView setText:]:发送到实例0x89625d0的选择器无法识别,iphone,ios,uiview,Iphone,Ios,Uiview,我试图在我的视图中添加一个自定义的复选框…我在我的故事板上画了一个视图,在名为“我正在访问它”的第三方代码的帮助下 UICheckbox.h #import <UIKit/UIKit.h> @interface UICheckbox : UIControl -(void)setChecked:(BOOL)boolValue; -(void)setDisabled:(BOOL)boolValue; -(void)setText:(NSString *)stringValue; @

我试图在我的视图中添加一个自定义的复选框…我在我的故事板上画了一个视图,在名为“我正在访问它”的第三方代码的帮助下

UICheckbox.h

#import <UIKit/UIKit.h>

@interface UICheckbox : UIControl

-(void)setChecked:(BOOL)boolValue;
-(void)setDisabled:(BOOL)boolValue;
-(void)setText:(NSString *)stringValue;

@property(nonatomic, assign)BOOL checked;
@property(nonatomic, assign)BOOL disabled;
@property(nonatomic, strong)NSString *text;

@end
在我的
视图中加载

self.checkbox.text = @"Want to get the updates directly";
我执行了这样的行动

-(IBAction)testCheckbox:(id)sender {
    NSLog(@"checkbox.checked = %@", (self.checkbox.checked) ? @"YES" : @"NO");
}
从故事板的角度来看……我把插座排成一行,并对相应的消息进行了润色,得到了这个错误


请帮助…

这很简单,但当我在代码中更改插座类型时,我得到了完全相同的错误-看起来它仍然连接在故事板中,但事实并非如此。我只需要将故事板中的插座(例如,标签)重新连接到代码插座。您不会想到这一点,因为插座仍然标记为已连接,但如果您进行了更改,则不会这样做。

您是如何初始化复选框以及在哪里分配UICheckBox的?.h文件@property(非原子,弱)中的IBOutlet UICheckBox*复选框;在.m文件中,合成checkbox viewdidLoad()self.checkbox.text=@“想要直接获取更新”的属性;尝试初始化复选框并将其作为子视图添加到self.view in ViewDiLoad中,然后再为复选框设置文本。另外,我认为您需要在UICheckBox自定义控件中重写initWithFrame:method删除然后重新创建出口修复了我的问题,并显示相同的错误消息
-(IBAction)testCheckbox:(id)sender {
    NSLog(@"checkbox.checked = %@", (self.checkbox.checked) ? @"YES" : @"NO");
}