Skip to content

Commit

Permalink
Prompt cell required width calculation wasn’t taking the UILabel’s fo…
Browse files Browse the repository at this point in the history
…nt into account so it wasn’t growing wide enough. Fix.
  • Loading branch information
mhupman committed Jan 14, 2014
1 parent aee54bd commit f01fb89
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions MBContactPicker/MBContactCollectionViewPromptCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,22 @@ - (void)setup

- (void)setPrompt:(NSString *)prompt
{
_prompt = prompt;
_prompt = prompt.copy;
self.promptLabel.text = prompt;
}

static UILabel *templateLabel;

+ (CGFloat)widthWithPrompt:(NSString *)prompt
{
if (!templateLabel)
{
templateLabel = [[UILabel alloc] init];
}

CGRect frame = [prompt boundingRectWithSize:(CGSize){ .width = CGFLOAT_MAX, .height = CGFLOAT_MAX }
options:NSStringDrawingUsesLineFragmentOrigin
attributes:nil
attributes:@{ NSFontAttributeName : templateLabel.font }
context:nil];
return ceilf(frame.size.width);
}
Expand Down

0 comments on commit f01fb89

Please sign in to comment.