PrettyKit icon indicating copy to clipboard operation
PrettyKit copied to clipboard

PrettyTableViewCell

Open jayrparro opened this issue 11 years ago • 3 comments

Xcode 6, iOS 8, using PrettyTableViewCell and the app is crashing related to KVO on line 481 - any idea?

- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 
{
    if ([keyPath isEqualToString:@"frame"]) 
    {        
        UIView *contentView = (UIView *) object;
        CGRect originalFrame = contentView.frame;

        float shadowMargin = [self shadowMargin];

        float y = contentView_margin;
        switch (self.position) {
            case PrettyTableViewCellPositionTop:
            case PrettyTableViewCellPositionAlone:
                y += shadowMargin;
                break;
            default:
                break;
        }
        float diffY = y - originalFrame.origin.y;

        if (diffY != 0)
        {
            CGRect rect = CGRectMake(originalFrame.origin.x+shadowMargin,
                                     originalFrame.origin.y+diffY,
                                     originalFrame.size.width - shadowMargin*2,
                                     originalFrame.size.height- contentView_margin*2 - [PrettyTableViewCell neededHeightForPosition:self.position tableStyle:_tableViewStyle]);
            contentView.frame = rect; // --> crash here!
        }
    }
}

jayrparro avatar Oct 16 '14 07:10 jayrparro

Found the same. It crashes due to recursion. If you test for (contentView.frame.origin.x != 0) and return, then the recursion is broken, but the size of the cells are wrong. I have not debugged it more than that.

henrikberg avatar Oct 24 '14 06:10 henrikberg

Hi,

change UI elements in main queue:

dispatch_async(dispatch_get_main_queue(), ^{
            contentView.frame = rect;
        });

Greetz Nils

ndressel avatar Oct 26 '14 19:10 ndressel

Had the same problem. Thx to ndressel it is fixed now. App doesn't crash anymore but when using PrettyCell CPU usage is about 100%. Any ideas?

Voidozzer avatar Feb 12 '15 09:02 Voidozzer