Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 14 #425

Open
isnifer opened this issue Jun 24, 2020 · 33 comments
Open

iOS 14 #425

isnifer opened this issue Jun 24, 2020 · 33 comments

Comments

@isnifer
Copy link

isnifer commented Jun 24, 2020

Issue

Looks like iOS 14 introduced new design for Calendar

Expected Behaviour

Looks like this component needs to be updated to handle these changes for iOS 14

Environment

  1. react-native -v: 0.62.2
  2. node -v: v10.18.1
  3. npm -v: 6.13.4
  4. yarn --version: 1.22.4
  5. target platform: iOS (14)
  6. operating system: macOS

image

@pramodsharma403
Copy link

Any update on this?

@karims10
Copy link

karims10 commented Jul 14, 2020

The question is: Is this lib still maintained ? 😕

@ashishkanhasoft
Copy link

@pramodsharma403 Have you get any solution for this issue?

@ymc-thzi
Copy link

ymc-thzi commented Aug 11, 2020

Same issue here. What I experienced now is that my app displays the datepicker correctly in the "old" way when the app is built with XCode 11. My current app live in the store (archived with XCode 11) running on a real device with iOS 14 beta 4 the Datepicker looks OK.
If I build/archive with XCode 12 beta 4 the DatePicker looks broken like the one above.

@undeaDD
Copy link

undeaDD commented Sep 14, 2020

one solution for this may be to override the preferedStyle of any UIDatePicker in the iOS native Workspace:

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

But there is one catch 👎
The DatePickerWheel is smaller in iOS14 and wont fill the Libraries Modal sadly
Maybe someone else here has any Idea for that ^^

If you are fine with a left aligned Wheel though just put the code from above in your AppDelegate -> didFinishLaunchingWithOptions function

IMAGE 2020-09-14 12:52:34

@undeaDD
Copy link

undeaDD commented Sep 14, 2020

okay i just fixed the misalignment with some customStyles ...

<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

Result: iOS 14 ( compiled with XCode 12 )
IMAGE 2020-09-14 13:53:47

@jithinlal
Copy link

were did you update the ios datepicker code? In workspace? @undeaDD

@undeaDD
Copy link

undeaDD commented Sep 17, 2020

Anywhere before the datepicker is loaded is fine ;)
I personally put it in the AppDelegate didFinishLaunching function 👍 so that it gets executed at App launch

@jithinlal
Copy link

Cool it worked

@burivuhster
Copy link

The solution from @undeaDD worked for me as well, thank you so much for sharing this.

@najielchemaly
Copy link

Hello, can anyone explain where to do the workaround for alignment issue? Knowing that if you do it inside the component rendering it only works when you save the file and after you open the picker again it goes left.. Any advise? Thanks

@miguelacio
Copy link

The solution @undeaDD provided worked just fine, but, I still kinda want to be able to use iOS 14 date picker, anyone has any approach to do this?

@syntag
Copy link

syntag commented Oct 22, 2020

We desperately need a new repository that's maintained for date picking.

@cameroncharles
Copy link

can confirm @undeaDD workaround works well enough

Real solution i think is to just go back to reactnative(community) date pickers which look to have come a long way since this libraries inception

@dhavalpanchani
Copy link

dhavalpanchani commented Nov 8, 2020

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

Check the full code here- #425 (comment)

if (@available(iOS 14, *)) {
  UIDatePicker *picker = [UIDatePicker appearance];
  picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}
  1. In DatePicker customStyles :
<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

@wo-xiaoxiao
Copy link

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

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

  1. In DatePicker customStyles :

<DatePicker
customStyles={{
datePicker: {
backgroundColor: '#d1d3d8',
justifyContent:'center'
}
}}
...
/>

Cool it worked

@dmitryshelomanov
Copy link

@wo-xiaoxiao on real device ?

@komelabbbas
Copy link

Any solution for expo..?
I have try many thing but not work.
Plz help

@uvrik
Copy link

uvrik commented Dec 14, 2020

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

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

  1. In DatePicker customStyles :

<DatePicker
customStyles={{
datePicker: {
backgroundColor: '#d1d3d8',
justifyContent:'center'
}
}}
...
/>

Hi, @dhavalpanchani
Thanks for your help, but can you show your appdelegate.m file code here, especially the rows where you added your code.
I think, we have different files, but i hope i can use your code for better understanding of what i have to do to make my datepicker work correctly =).

@dhavalpanchani
Copy link

dhavalpanchani commented Dec 14, 2020

@uvrik : Sure, here it's.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  
  if (@available(iOS 14, *)) {
    UIDatePicker *picker = [UIDatePicker appearance];
    picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
  }
  
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"App"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
    
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
  return YES;
}

@vhuerta
Copy link

vhuerta commented Jan 20, 2021

Found a work around for expo apps without eject:

  1. Install this fork that allows using a custom datepicker controller for iOS (https://github.com/codynguyen/react-native-datepicker/tree/ios-datepicker-component) with:
 npm install git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component --save
  1. Install @react-native-community/datetimepicker
npm install --save @react-native-community/datetimepicker
  1. Add this prop to your datepicker
import RNDatePicker from '@react-native-community/datetimepicker';
// ...
<DatePicker 
    iOSDatePickerComponent={(props) => (<RNDatePicker {...props} display={Platform.OS === 'ios' ? 'spinner' : 'default' }/>)} 
/>

enjoy :)

@aliiqbal436
Copy link

@vhuerta this solution is not working for expo.

@vhuerta
Copy link

vhuerta commented Feb 11, 2021

@aliiqbal436 have it working on my own expo app, these are my versions

"react-native-datepicker": "git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component",
"@react-native-community/datetimepicker": "^3.0.9",

I think expo installs a different @react-native-community/datetimepicker version

@aliiqbal436
Copy link

aliiqbal436 commented Feb 12, 2021

"@react-native-community/datetimepicker": "3.0.9", "react-native-datepicker": "git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component",
@vhuerta I also have the same versions.

@ikismail
Copy link

ikismail commented Mar 2, 2021

Found a work around for expo apps without eject:

  1. Install this fork that allows using a custom datepicker controller for iOS (https://github.com/codynguyen/react-native-datepicker/tree/ios-datepicker-component) with:
 npm install git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component --save
  1. Install @react-native-community/datetimepicker
npm install --save @react-native-community/datetimepicker
  1. Add this prop to your datepicker
import RNDatePicker from '@react-native-community/datetimepicker';
// ...
<DatePicker 
    iOSDatePickerComponent={(props) => (<RNDatePicker {...props} display={Platform.OS === 'ios' ? 'spinner' : 'default' }/>)} 
/>

enjoy :)

Works like charm.. Thanks @vhuerta 👍

@telltokichu
Copy link

These two things worked for me only in Development mode .

Add below code in didFinishLaunching function in appdelegate.m :
if (@available(iOS 14, *)) {
UIDatePicker *picker = [UIDatePicker appearance];
picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}

In DatePicker customStyles :
<DatePicker
customStyles={{
datePicker: {
backgroundColor: '#d1d3d8',
justifyContent:'center'
}
}}
...
/>

but after building it in release mode in ios, I'm getting like this

Screenshot 2021-03-05 at 3 05 14 PM

any fix ?

@adaniels5201
Copy link

These two things worked for me only in Development mode .

Add below code in didFinishLaunching function in appdelegate.m :
if (@available(iOS 14, *)) {
UIDatePicker *picker = [UIDatePicker appearance];
picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}

In DatePicker customStyles :
<DatePicker
customStyles={{
datePicker: {
backgroundColor: '#d1d3d8',
justifyContent:'center'
}
}}
...
/>

but after building it in release mode in ios, I'm getting like this

Screenshot 2021-03-05 at 3 05 14 PM

any fix ?

Looks like a dark mode issue. Do you have the same view in light mode?

@telltokichu
Copy link

yes It was issue with dark mode - after changing uiappearance mode in xcode to light - it got fixed

@syedamirali14
Copy link

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

Check the full code here- #425 (comment)

if (@available(iOS 14, *)) {
  UIDatePicker *picker = [UIDatePicker appearance];
  picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}
  1. In DatePicker customStyles :
<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

this worked for my xcode 11.1

@ksjmb
Copy link

ksjmb commented May 4, 2021

okay i just fixed the misalignment with some customStyles ...

<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

Result: iOS 14 ( compiled with XCode 12 )
IMAGE 2020-09-14 13:53:47

Thank you, it will work for me

@ioswmtdeveloper
Copy link

@uvrik : Sure, here it's.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  
  if (@available(iOS 14, *)) {
    UIDatePicker *picker = [UIDatePicker appearance];
    picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
  }
  
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"App"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
    
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
  return YES;
}

Mind blowing. Easiest solution !!!!!!

@YaarPatandarAA
Copy link

YaarPatandarAA commented Jul 29, 2021

Workaround by @undeaDD confirmed still working. 👍🏻

@maheshwarimrinal
Copy link

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

Check the full code here- #425 (comment)

if (@available(iOS 14, *)) {
  UIDatePicker *picker = [UIDatePicker appearance];
  picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}
  1. In DatePicker customStyles :
<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

This works like a charm!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests