Skip to content

Commit

Permalink
Overrides sizeThatFits: instead of sizeToFit
Browse files Browse the repository at this point in the history
Documentation says "You should not override this method. If you want to change the default sizing information for your view, override the sizeThatFits: instead. That method performs any needed calculations and returns them to this method, which then makes the change."
  • Loading branch information
Insoo Kim committed Sep 9, 2013
1 parent bc08308 commit 2351e01
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions SMPageControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,11 @@ - (UIImage *)imageMaskForPage:(NSInteger)pageIndex
return [self _imageForPage:pageIndex type:SMPageControlImageTypeMask];
}

- (void)sizeToFit
- (CGSize)sizeThatFits:(CGSize)size
{
CGRect frame = self.frame;
CGSize size = [self sizeForNumberOfPages:self.numberOfPages];
size.height = MAX(size.height, MIN_HEIGHT);
frame.size = size;
self.frame = frame;
CGSize sizeThatFits = [self sizeForNumberOfPages:self.numberOfPages];
sizeThatFits.height = MAX(sizeThatFits.height, MIN_HEIGHT);
return sizeThatFits;
}

- (void)updatePageNumberForScrollView:(UIScrollView *)scrollView
Expand Down

0 comments on commit 2351e01

Please sign in to comment.