Skip to content

Commit

Permalink
fixed endless loop in layout subviews if the title is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
renep committed Feb 22, 2013
1 parent 75f504f commit a6ea226
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions Core/Source/iOS/DTActivityTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ - (id)init
- (void)layoutSubviews
{
[super layoutSubviews];

CGFloat gap = 5.0;
CGFloat height = self.activityIndicator.frame.size.height;
CGSize neededSize = [self.titleLabel.text sizeWithFont:self.titleLabel.font];

if (height < neededSize.height)
{
height = neededSize.height;
}

CGRect titleRect = CGRectMake(self.activityIndicator.frame.size.width+gap, 0, neededSize.width, height);
self.titleLabel.frame = titleRect;
self.bounds = CGRectMake(0, 0, self.activityIndicator.frame.size.width+neededSize.width+gap, height);
}

#pragma mark - Properties
Expand All @@ -93,6 +80,18 @@ - (BOOL)busy
- (void)setTitle:(NSString *)title
{
self.titleLabel.text = title;
CGFloat gap = 5.0;
CGFloat height = self.activityIndicator.frame.size.height;
CGSize neededSize = [self.titleLabel.text sizeWithFont:self.titleLabel.font];

if (height < neededSize.height)
{
height = neededSize.height;
}

CGRect titleRect = CGRectMake(self.activityIndicator.frame.size.width+gap, 0, neededSize.width, height);
self.titleLabel.frame = titleRect;
self.bounds = CGRectMake(0, 0, self.activityIndicator.frame.size.width+neededSize.width+gap, height);
[self setNeedsLayout];
}

Expand Down

0 comments on commit a6ea226

Please sign in to comment.