filipealva / PickerView

🔸 A customizable alternative to UIPickerView in Swift.
MIT License
527 stars 92 forks source link

iOS 11, iPhone 7 Simulator, Xcode Version 9.0 beta 6 (9M214v) - Initial selected values not aligned. #30

Closed neilt closed 7 years ago

neilt commented 7 years ago

Selected values don't line up. Not sure if it is the PickerView or Apple, but here it is, none-the-less.

screen shot 2017-08-29 at 4 22 32 pm

When I click on the number 9 in the first picker it does this.

screen shot 2017-08-29 at 4 30 40 pm

If i scroll all pickers to the top (0) then back to the correct value, then it looks correct.

screen shot 2017-08-29 at 4 35 26 pm

Thereafter it seems to work correctly.

luisfsresende commented 7 years ago

Have the same problem. Any plans to look into this?

neilt commented 7 years ago

Can confirm this is still a problem with Xcode 9 GM. The following test results were from an application compiled with the Xcode 9 GM SDK.

  1. iPhone SE Hardware iOS 10.3.3, does NOT exhibit the problem.
  2. iPhone SE Simulator iOS 10.3.1, does NOT exhibit the problem.
  3. iPhone SE Simulator iOS 11.0 does exhibit the problem.

From our limited testing it appears to be an iOS issue and not an SDK issue. We anticipate this will effect existing users upgrading to iOS 11.

filipealva commented 7 years ago

Hey guys,

Thanks for reporting.

I'm on it. As soon as I fix it I'll release a new version of PickerView.

filipealva commented 7 years ago

Update: It looks like the problem is with the initial calculations of the tableView's content size property.

Something behind the sdk scenes might have changed a bit and is causing it to calculate the content size wrong despite there is no change to the code base.

It's not fixed yet but I'm working to fix and release a new version as soon as possible.

AlexanderPravodudov commented 7 years ago

Hi guys, have the same issues, the main problem it's xcode version 9.0 you should use actual version of xcode 8.3.3 fоr example, don't use beta version. When i build my project from xcode 8.3.3 everything is ok, but if i try do the same from xcode 9.0 problem come back.

filipealva commented 7 years ago

It looks like I managed to fix it! 🤘

I'll soon release a new version of PickerView with this fix. If you guys want to take a look on the fixed version please look into this branch.

The solution: In iOS 11 the UITableView uses the value of estimatedRowHeight (even if you didn't set it) to calculate the contentSize. I was not setting any value to this property and because of it the contentSizewas being calculated wrong by the UITableVIew. Once the user scrolls it the UITableVIew seems to detect that the contentSize is not fitting the real content and then calls the delegate method heightForRowAtIndexPath to fix the contentSize.

By setting all the "estimated" properties of the UITableVIew to zero we cancel this new behavior of iOS 11 and the UITableVIew look directly into heightForRowAtIndexPath to calculate the contentSize.

neilt commented 7 years ago

I can confirm that your fix does indeed fix the problem in iOS 11 and does not cause any additional problems with iOS 10.3.3, which continues to work correctly.

Thank you.

filipealva commented 7 years ago

0.3.2

Hey guys,

The new version has been released. Please let me know if everything is working.

neilt commented 7 years ago

Working for me, thanks.