Rav*_*avi 7 objective-c uiswitch
我们可以更改UISwitch上的文本,即On&Off.我尝试了以下代码,但它崩溃了
系统崩溃日志:
由于未捕获异常而终止应用程序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;
Run Code Online (Sandbox Code Playgroud)