7

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;    
4

2 に答える 2

5

これを使って

http://www.catamount.com/blog/1063/uicustomswitch-customizing-uiswitch-color-it-change-labels/

于 2011-05-23T12:26:40.153 に答える
3

これを見てください:http://osiris.laya.com/projects/rcswitch/ それは多くのカスタマイズ(テキストを含む)を可能にしています

于 2011-05-23T12:31:49.160 に答える