toppless
toppless

Reputation: 411

Custom UIControl within UITableView

I have a custom UIControl which can have two custom states -> customEnabled / customDisabled. State change of this UIControl results technically in hiding / displaying defined view for the state set. Work fine so far.

When using within the UITableView I have the following problem: When reusing a cell with enabled control for a cell, where control is disabled I see for a short time the enabled and then disabled control.

State setting is happening in the cellForRowAtIndexPath method of the UITableViewController. The setter for the state shows / hides the views.

Does anyone have an idea how to get the appropriate appearance without "animation"?

Upvotes: 0

Views: 460

Answers (2)

Jeffery Thomas
Jeffery Thomas

Reputation: 42588

I was going to suggest something similar

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

Upvotes: 0

Ivan Nikitin
Ivan Nikitin

Reputation: 4125

Wrap your showing/hiding in the following

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

Upvotes: 1

Related Questions