akkyie / AKPickerView-Swift

A simple yet customizable horizontal picker view.
MIT License
576 stars 173 forks source link

Picker view not inside view constraints #45

Open corbrink opened 8 years ago

corbrink commented 8 years ago
grab

Hi, I've been trying to resize the picker view so that the items are displayed inside the view.

In my storyboard I added a View, 100 x 40, and referenced it to AKPickerView. However when I run the code there is nothing inside the view. When I make the view bigger and run it the items are visible inside the bigger view. The little rectangle right of 4 is an imageView which seems the lower the last value so that it is not in line with the rest. Is there a way to remove this?

How do I change the code to ensure that the items are displayed in the smaller View?

corbrink commented 8 years ago

I'll answer this myself after I read #20. I also had the picker view in a navigation controller. After disabling the top bar in the view, not navC, the problem was resolved and the picker displays correctly. This is however an issue that I think needs to be resolved. Great code by the way, thanks!

Akkyie you can close if you want.

Robertof commented 7 years ago

Just a heads up: I faced the same issue, and hiding the top bar didn't help.

Here's what I did that fixed it:

picker.superview?.bringSubview (toFront: picker)

This is Swift 3, BTW. And it works like a charm!

terencepalmer commented 7 years ago

This seems to be caused by UICollectionView. AKPickerView works great for me in one view that is not embedded in a navigation controller, but the labels are not visible when it is embedded in a navigation controller. Robertof's solution did not work for me. Disabling the navigation bar doesn't seem like a good solution, because I want the navigation bar. What does work for me is putting either:

self.automaticallyAdjustsScrollViewInsets = false

Or:

navigationController?.navigationBar.isTranslucent = false

in my ViewController.