Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes scrollView.contentSize resizing #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions VENTokenField/VENTokenField.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,7 @@ - (void)reloadData

self.tokens = [NSMutableArray array];

CGFloat currentX = 0;
CGFloat currentY = 0;

[self layoutToLabelInView:self.scrollView origin:CGPointZero currentX:&currentX];
[self layoutTokensWithCurrentX:&currentX currentY:&currentY];
[self layoutInputTextFieldWithCurrentX:&currentX currentY:&currentY];

[self adjustHeightForCurrentY:currentY];
[self.scrollView setContentSize:CGSizeMake(self.scrollView.contentSize.width, currentY + [self heightForToken])];
[self __commitLayoutSubviews];

[self updateInputTextField];

Expand Down Expand Up @@ -187,6 +179,32 @@ - (NSString *)inputText

#pragma mark - View Layout

- (void)layoutSubviews {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with our style:

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self commitLayoutSubviews];
}


[super layoutSubviews];

[self __commitLayoutSubviews];
}

- (void)__commitLayoutSubviews {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- (void)commitLayoutSubviews
{

please 😸


self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.frame) - self.horizontalInset * 2, CGRectGetHeight(self.frame) - self.verticalInset * 2);
self.scrollView.contentInset = UIEdgeInsetsMake(self.verticalInset,
self.horizontalInset,
self.verticalInset,
self.horizontalInset);

CGFloat currentX = 0;
CGFloat currentY = 0;

[self layoutToLabelInView:self.scrollView origin:CGPointZero currentX:&currentX];
[self layoutTokensWithCurrentX:&currentX currentY:&currentY];
[self layoutInputTextFieldWithCurrentX:&currentX currentY:&currentY];

[self adjustHeightForCurrentY:currentY];
[self.scrollView setContentSize:CGSizeMake(self.scrollView.contentSize.width, currentY + [self heightForToken])];
}

- (void)layoutScrollView
{
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))];
Expand Down