- (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?