【问题标题】:Custom UIControl within UITableViewUITableView 中的自定义 UIControl
【发布时间】:2012-07-19 22:03:01
【问题描述】:

我有一个自定义 UIControl,它可以有两个自定义状态 -> customEnabled / customDisabled。此UIControl 的状态更改在技术上会导致隐藏/显示状态集的已定义视图。到目前为止工作正常。

在UITableView 中使用时,我遇到了以下问题:当重新使用一个启用了控件的单元格时,我在短时间内看到了启用的控件,然后又禁用了控件。

状态设置发生在UITableViewController 的cellForRowAtIndexPath 方法中。状态的设置器显示/隐藏视图。

有没有人知道如何在没有“动画”的情况下获得适当的外观?

【问题讨论】:

  • 一点代码就能帮助我们。

标签: iphone objective-c ios uicontrol


【解决方案1】:

将您的显示/隐藏包装在以下内容中

[CATransaction begin]; 
[CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions];
// do show/hide
[CATransaction commit];

【讨论】:

  • 谢谢!这样可行。这是否意味着隐藏的属性更改是默认动画的?
  • 是的,他们是。如果解决了问题,请将帖子标记为答案。
【解决方案2】:

我打算提出类似的建议

[UIView setAnimationsEnabled:NO];
[UIView animateWithDuration:0.0 animations:^{
    // Code with animations turned off
} completion:^(BOOL finished){
    [UIView setAnimationsEnabled:YES];
}];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-11
    • 2011-07-09
    • 2017-10-02
    • 2023-03-30
    • 2012-09-01
    • 1970-01-01
    相关资源
    最近更新 更多