【发布时间】:2014-11-27 03:58:06
【问题描述】:
我有一个UISwitch,它位于UITableViewCell 的内部。我有一个分配给 switch 的目标操作:
[switch addTarget:self action:@selector(changeSwitchColor:) forControlEvents:UIControlEventValueChanged];
- (void)changeSwitchColor:(id)sender
{
...
}
问题是changeSwitchColor:在动画结束之前被调用,但我想检测动画何时结束,所以我可以设置thumbTintColor属性而不破坏动画。
我尝试使用UIViewsetAnimationDidStopSelector:方法检测动画:
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
...
}
但是UISwitch完成动画时不会调用此方法(我什至不确定动画是如何内部制作的)。
如何检测UISwitch的完成状态?
谢谢!
【问题讨论】:
-
你可以从另一个stackoverflow答案链接找到你的答案:stackoverflow.com/questions/19628310/…
-
这个问题究竟如何回答我的问题?
-
UISwitch是一个不好的课程。很难覆盖或自定义。我认为您应该覆盖UIControl并进行自己的切换 -
我真的很想避免自己切换,我当然知道
UIControl。