vicpenap / PrettyKit

PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization. You will be able to change their background color, add gradients, shadows, etc.
http://vicpenap.github.com/PrettyKit
Other
1.22k stars 155 forks source link

PrettyTableViewCell #48

Open jayrparro opened 10 years ago

jayrparro commented 10 years ago

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!
        }
    }
}
henrikberg commented 10 years ago

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.

ndressel commented 10 years ago

Hi,

change UI elements in main queue:

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

Greetz Nils

Voidozzer commented 9 years ago

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?