我们可以更改 UISwitch 上的文本,即 On & Off。我尝试了以下代码,但它崩溃了
崩溃日志:
由于未捕获的异常 NSInvalidArgumentException 而终止应用程序,原因:'-[UISwitch setLeftLabelText:]: unrecognized selector sent to instance 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;