PrettyKit
PrettyKit copied to clipboard
PrettyTableViewCell
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!
}
}
}
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.
Hi,
change UI elements in main queue:
dispatch_async(dispatch_get_main_queue(), ^{
contentView.frame = rect;
});
Greetz Nils
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?