StefanLage / SLPagingView

Navigation bar system allowing to do a Tinder like or Twitter like
MIT License
1.01k stars 85 forks source link

PickerView goes nuts inside SLPagingView #37

Closed d3vtoolsmith closed 9 years ago

d3vtoolsmith commented 9 years ago

I've been having an issue using the standard PickerView (spinning wheel) not only inside one of the view controllers under the purview of SLPagingViewController, but also inside of modal popups that seems shouldn't be affected by it. Basically, the spinning-wheel wobbles in every possible direction, doesn't rotate properly at all, with tapping (not swiping/spinning) being the only way to select a value.

Below are the screenshots of how it looks when you try to spin it. To experience, simply add the most basic PickerView implementation to the TinderStoryboard example (code below). Any thoughts on how to fix this would be helpful since I'm yet to find a solution/cause.

ios simulator screen shot jun 29 2015 13 17 08 ios simulator screen shot jun 29 2015 13 17 01 ios simulator screen shot jun 29 2015 13 16 57

CODE:

- (void)viewDidLoad {
    [super viewDidLoad];
    UIImage *logo = [UIImage imageNamed:@"profile"];
    logo = [logo imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    _titleView = [[UIImageView alloc] initWithImage:logo];
    self.navigationItem.titleView = self.titleView;
    // Do any additional setup after loading the view, typically from a nib.

    self.pickerView.delegate = self;
    self.pickerView.dataSource = self;
    _pickerData = @[@"Item 1", @"Item 2", @"Item 3", @"Item 4", @"Item 5", @"Item 6"];
}

NSArray *_pickerData;

- (int)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

- (int)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return _pickerData.count;
}

- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return _pickerData[row];
}
harkmall commented 9 years ago

+1 I'm having this problem too, mine is happening with date pickers.

d3vtoolsmith commented 9 years ago

Date pickers are based on the PickerView, so yeah. Unfortunately I ended up having to switch to a similar library that doesn't have this or a number of other issues with this library. Make sure to Clean your project after you switch. I'm now working ridding myself of the phobia of using PickerView controls in iOS :) This is the library (it also works with sotryboards even though there's no example): https://github.com/Tgy31/THTinderNavigationController

lays90 commented 8 years ago

I've just solved this problem by modifying the -(void)setFrame:(CGRect)frame and -(void)updateConstraints methods in the "UIScrollView+UpdateContentSize.m" file, and here is my code:

#pragma mark - OVERRIDE
-(void)setFrame:(CGRect)frame{
    [super setFrame:frame];
    // Scale the content size
    Class UIPickerTableView = NSClassFromString(@"UIPickerTableView");
    if ([self class] == UIPickerTableView) {
        return;
    }else {
        [self updateContentSize];
    }
}

-(void)updateConstraints{
    [super updateConstraints];
    // Scale the content size
    Class UIPickerTableView = NSClassFromString(@"UIPickerTableView");
    if ([self class] == UIPickerTableView) {
        return;
    }else {
        [self updateContentSize];
    }
}

This works and wish it could help you too.