我子类一个UILabel并添加2个属性看起来像这样:为什么我的动作不会响应选择器?
@property (nonatomic, assign) SEL action;
@property (nonatomic, assign) id target;
我再实施的UIView的接触开始的方法是这样的:在类中
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([target respondsToSelector:@selector(action)]) {
[target performSelector:@selector(action) onThread:[NSThread mainThread] withObject:nil waitUntilDone:NO];
}
}
包含的子类的UILabel,我设置目标和动作是这样的:
label.target = self;
labek.action = @selector(myMethod);
label.userInteractionEnabled = YES;
包含该标签的类确实具有方法myMethod,因此它显示uld回应它。任何想法,为什么它可能不?
谢谢!
真棒作品像一个魅力谢谢 –