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

Incorrect picker width #3

Open
IvanDev opened this issue Aug 26, 2016 · 1 comment
Open

Incorrect picker width #3

IvanDev opened this issue Aug 26, 2016 · 1 comment

Comments

@IvanDev
Copy link

IvanDev commented Aug 26, 2016

Hello gklka,
Thank you for this control, I noticed layout issue on wide devices. I don't have time to make normal pull request, but here is my fix for this issue. Hope this helps someone.

In order to fix picker width issue on wide devices (e.g. iPhone 6), you need to call setNeedsLayout and layoutIfNeeded.
You can fix it at GKActionSheetPicker.m: 444 so it looks like this:

// Add picker
    if (self.pickerType == GKActionSheetPickerTypeString ||
        self.pickerType == GKActionSheetPickerTypeMultiColumnString) {

        self.pickerView.frame = CGRectMake(0, ToolbarHeight, hostFrame.size.width, PickerViewHeight);
        self.pickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        [self.pickerContainerView addSubview:self.pickerView];

        [self.pickerView setNeedsLayout];
        [self.pickerView layoutIfNeeded];
    } else if (self.pickerType == GKActionSheetPickerTypeDate) {

        self.datePicker.frame = CGRectMake(0, ToolbarHeight, hostFrame.size.width, PickerViewHeight);
        self.datePicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        [self.pickerContainerView addSubview:self.datePicker];
        [self.datePicker addTarget:self action:@selector(datePickerDidChangeValue:) forControlEvents:UIControlEventValueChanged];

        [self.datePicker setNeedsLayout];
        [self.datePicker layoutIfNeeded];
    }
@gklka
Copy link
Owner

gklka commented Aug 28, 2016

This does not work for me. Even the "Basic" example sticks at the previous orientation's width. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants