我们可以更改uiSwitch上的文本

问题描述:

我们可以更改UISwitch上的文本,即打开&关。我已经尝试下面的代码,但其崩溃我们可以更改uiSwitch上的文本

崩溃日志:

终止应用程序由于未捕获的异常NSInvalidArgumentException,原因: ' - [UISwitch setLeftLabelText:]:无法识别的选择发送到实例0x4c65020' **

switcher = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease]; 
[switcher addTarget:self action:@selector(switchAction:) 
forControlEvents:UIControlEventValueChanged]; 

// swit = [[UISwitch alloc] initWithFrame:CGRectZero]; 
[switcher setCenter:CGPointMake(160.0f,260.0f)]; 
[switcher setLeftLabelText: @"Female"]; 
[switcher setRightLabelText: @"Male"]; 
[[switcher rightLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; 
[[switcher leftLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; 
[[switcher leftLabel] setTextColor:[UIColor yellowColor]]; 

cell.accessoryView = switcher; 
switcher.tag = indexPath.row;  

看一看这个:http://osiris.laya.com/projects/rcswitch/ 它允许很多定制(包括文本)