hackiftekhar / IQActionSheetPickerView

ActionSheet with UIPickerView
MIT License
205 stars 76 forks source link

Cancel Done buttons are unclickable while using in ScrollView with ios 7.1 #4

Closed soner-yuksel closed 10 years ago

soner-yuksel commented 10 years ago

First of all thanks for the pickerview, it makes things much easier.

However there is strange bug if you want to use it with scroll view.

If you use IQActionSheetPickerView in a controller that has scroll view on top and scroll the view down and click a button for example triggering pickerview. The size of the pickerview is getting extended and buttons are not clickable anymore.

Did you come up with this before?

hackiftekhar commented 10 years ago

Hi Reapert, First of all thanks for your bug report. I didn't come up with this issue before. Can you provide me the sample code so it will be easy to debug my side. I will try to fix it if possible.

Thanks Iftekhar

soner-yuksel commented 10 years ago

Hi Iftekhar

Your quick reply appreciated. I sent the sample project to your email address.

Thanks Reapert

hackiftekhar commented 10 years ago

Thanks for the sample code. I found the issue and fixed it.

Actual Problem:- The problem is with UIScrollView. Your self.view is actually UIScrollView object. that causes it's bounds property to be adjusted according to it's contentOffset.

Fix:- Recalculated the bounds of self.view fixed this issue. here is the updated code for "-(void)showInView:(UIView *)view" implementation.

-(void)showInView:(UIView *)view
{
    [_pickerView reloadAllComponents];

    [super showInView:view];

    [UIView animateWithDuration:0.3 animations:^{
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        {
            CGRect bounds = CGRectZero;
            bounds.size = view.bounds.size;
            [self setBounds:bounds];
            [self setFrame:CGRectMake(CGRectGetMinX(self.frame), CGRectGetHeight(bounds)-CGRectGetHeight(_actionToolbar.bounds)-CGRectGetHeight(_pickerView.bounds), CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))];
        }
    }];   
}

I also updated code on github. Again many many thanks for your bug report.

Thanks Iftekhar

soner-yuksel commented 10 years ago

Hey İftekhar,

Many many many thanks for quick and perfectly working solution.

With the final fix, I guess your classes are the best and effective ones among others for actionpicker view problem.

Kind Regards Reapert