tobihagemann / THLabel

UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.
https://tobiha.de
Other
665 stars 111 forks source link

Crashes in UITableViewCell #5

Closed brianantonelli closed 10 years ago

brianantonelli commented 10 years ago

There seems to be a problem with using THLabel inside of a UITableViewCell. In my app I have a cell (defined in a storyboard) and I'm setting the text value in my cellForRowAtIndexPath method. Once I scroll and the cell gets recycled it crashes as soon as the setText method is called on the label.

Here's a snippet from my controller:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    THLabel *photoCount = (THLabel*)[cell viewWithTag:101];
    photoCount.strokeColor = [UIColor whiteColor];
    photoCount.strokeSize = 1.0f;
    photoCount.strokePosition = THLabelStrokePositionOutside;
    photoCount.text = @"TEST";
}

*\ -[CFString class]: message sent to deallocated instance 0x95c3f60

I'm assuming its crashing in the - (CTFrameRef)setupFrameForDrawingOutTextRect:(CGRect *)textRect method.

tobihagemann commented 10 years ago

I can reproduce the issue, but I'll need some time to look into it. What I can't reproduce is to see where it crashes. I'm just receiving a EXC_BAD_ACCESS signal at [UILabel setText:], which is weird. When I find something, I'll get back to you!

tobihagemann commented 10 years ago

Remove the line "CFRelease(stringRef);", then it should work... I'll update THLabel, if you can confirm that it works.

brianantonelli commented 10 years ago

Perfect! Thanks!