datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Different UI on iOS 14

Open pavermakov opened this issue 6 years ago • 60 comments

Summary

I am currently preparing my app for the iOS 14. I have noticed that the date picker is not what it used to be.

Here is what it looks like on iOS 13.7:

Снимок экрана 2020-09-21 в 16 31 16

Here is the iOS 14 version: Снимок экрана 2020-09-21 в 16 22 57

Simulator Screen Shot - iPhone 11 Pro Max - 2020-09-21 at 16 23 01

There is now an extra step, instead of spinning the wheel, I need to press it to trigger another calendar popup.

I use display: "spinner" prop.

Is there any way I can still use the wheel on iOS 14?

Environment info

react-native info output:

System:
    OS: macOS 10.15.5
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 391.89 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.0 - /usr/local/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.9.3 - /Users/pavelermakov/.rvm/gems/ruby-2.6.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15
    Android SDK:
      API Levels: 23, 24, 25, 26, 27, 28, 29
      Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.3, 27.0.0, 27.0.1, 27.0.3, 28.0.0, 28.0.2, 28.0.3, 29.0.3
      System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-27 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6392135
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_171 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.2 => 0.63.2
    react-native-macos: Not Found

Library version: 3.0.2

pavermakov avatar Sep 21 '20 14:09 pavermakov

I am having the same issue. The user flow is actually correct. That is how the new date picker from iOS 14 works, but the styling is a bit broken / not optimized for the new flow.

jChris85 avatar Sep 21 '20 15:09 jChris85

facing the same issue, it makes users have to click two times to choose the date. any help on this?

ajengrf avatar Sep 21 '20 20:09 ajengrf

I found a quick fix for this issue. You can override your preferred Style of the UIDatePicker in your native iOS workspace. Just add the following lines of code in the function didFinishLaunchingWithOptions in your ios/APP_NAME/AppDelegate file.

if (@available(iOS 14, *)) {
  UIDatePicker *picker = [UIDatePicker appearance];
  picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}

After restarting your app the date picker should show the old wheel style. This fix can be removed after this package is updated with the new user flow and styling for the iOS 14 date picker.

jChris85 avatar Sep 21 '20 21:09 jChris85

@jChris85 That works, thank you!

pavermakov avatar Sep 22 '20 04:09 pavermakov

@pavermakov I'm glad this is working for you. However, we should leave the issue open until this package is updated.

jChris85 avatar Sep 22 '20 07:09 jChris85

Regarding the documentation setting the prop display to spinner worked for me as well without the need of the native "fix".

jChris85 avatar Sep 22 '20 12:09 jChris85

@jChris85 you're a legend. Thaaanks

joaom182 avatar Sep 22 '20 23:09 joaom182

display={Platform.OS === 'ios' ? 'inline' : 'default'}

yt-dev avatar Sep 23 '20 05:09 yt-dev

Setting display="spinner" still showing new default ios14 UI

I've deleted npm packages, cleared cache, reinstalled, cleared pod cache, and reinstalled pods. Same behavior.

daybreaker avatar Sep 24 '20 17:09 daybreaker

@daybreaker I have to use the react-native-date-picker at the moment.

vinhnglx avatar Sep 25 '20 00:09 vinhnglx

I noticed that in a brand new project the display options were working correctly, and so I tried deleting all caches with the following commands, and it worked.

watchman watch-del-all && 
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* && 
rm -rf node_modules/ 
&& npm cache clean --force &&
npm install && 
npm start -- --reset-cache

rodrigoarantes avatar Sep 25 '20 12:09 rodrigoarantes

Setting display="spinner" still showing new default ios14 UI

I've deleted npm packages, cleared cache, reinstalled, cleared pod cache, and reinstalled pods. Same behavior.

@daybreaker: Try to delete all available cache files and then restart your app.

Solution provided by @rodrigoarantes

I noticed that in a brand new project the display options were working correctly, and so I tried deleting all caches with the following commands, and it worked.

watchman watch-del-all && 
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* && 
rm -rf node_modules/ 
&& npm cache clean --force &&
npm install && 
npm start -- --reset-cache

jChris85 avatar Sep 25 '20 13:09 jChris85

@jChris85 @rodrigoarantes Thanks a bunch - that seems to have done the trick! I wasnt deleting enough caches! :-P

daybreaker avatar Sep 26 '20 00:09 daybreaker

if (@available(iOS 14, *)) { UIDatePicker *picker = [UIDatePicker appearance]; picker.preferredDatePickerStyle = UIDatePickerStyleWheels; }

Hi @jChris85, I want to display center Can you help me pls?

image

phuocantd avatar Sep 28 '20 08:09 phuocantd

@phuocantd this was happening to me too, when trying the AppDelegate.m hack

Try removing that, and doing the cache deletion steps @rodrigoarantes mentioned:

watchman watch-del-all && 
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* && 
rm -rf node_modules/ 
&& npm cache clean --force &&
npm install && 
npm start -- --reset-cache

Deleting all the caches and restarting brought back the old, centered spinner.

daybreaker avatar Sep 28 '20 15:09 daybreaker

facing the same issue, it makes users have to click two times to choose the date. any help on this?

Facing same

m4devgeek avatar Sep 28 '20 15:09 m4devgeek

@m4devgeek This is the new iOS 14 date picker behaviour. However, did you try the solutions provided in this thread?

To reset the date picker to use the spinner wheel follow these steps:

  1. Set the date picker prop display to spinner
  2. Delete all cache files
watchman watch-del-all && 
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* && 
rm -rf node_modules/ 
&& npm cache clean --force &&
npm install && 
npm start -- --reset-cache
  1. restart your app

jChris85 avatar Sep 28 '20 17:09 jChris85

This works locally but when it goes though my build server, bitrise, I get the following error:

ios/MY_APP/AppDelegate.m:54:39: use of undeclared identifier 'UIDatePickerStyleWheels'
picker.preferredDatePickerStyle = UIDatePickerStyleWheels;

Any ideas?

donaldparker avatar Sep 29 '20 21:09 donaldparker

@donaldparker you need to use xcode 12, that should make the error go away

vonovak avatar Sep 29 '20 21:09 vonovak

Yes that fixed the issue, thank you.

donaldparker avatar Sep 29 '20 22:09 donaldparker