- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.sw = [[[UISwitch alloc] initWithFrame:CGRectMake(210, 8, 50, 30)] autorelease];
[sw setOn:YES];
[sw addTarget:self action:@selector(switchChanged) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:sw];
}
return self;
}
-(void)switchChanged
{
// [self setImage];
[sw setOn:NO];
if (_delegate && [_delegate respondsToSelector:@selector(selectedWith:)]){
[_delegate selectedWith:self];
}
}
スイッチをクリックすると、関数 switchChanged が呼び出されませんか?