UIDatePicker Flips on iOS9 RTL

I have a weird issue when displaying a DatePicker - Time mode on RTL.

Im displaying the date picker programmatically. Minutes should be on the right side, and hours on the left, and on the following image you can see it's flipped:

It happens on iOS 9 and above.

The code I'm using:

UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height+44, self.view.frame.size.width, 216)];
datePicker.tag = tag;
[datePicker setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
[datePicker setDatePickerMode:UIDatePickerModeTime];
[datePicker setBackgroundColor:[UIColor whiteColor]];
[datePicker addTarget:self action:@selector(changeDate:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:datePicker];

Any suggestions ?

I think this is a side-effect of your setting .ForceRightToLeft on UIView's appearance proxy.

If that's the case, please note that this is not a supported use case. Your app should only be in RTL if it's:

a) localized into an RTL language, and

b) the device's system language is set to that language.

ios - UIDatePicker Flips on iOS9 RTL, I think this is a side-effect of your setting .ForceRightToLeft on UIView 's appearance proxy. If that's the case, please note that this is not a supported use case. I used UIDatePicker in my ViewController. it worked fine on iOS 8.x, but when I run it on iOS 9.x devices,it crashed. I have tried to create a new project to use UIDatePicker in the same way and it worked fine on all iOS devices. So, my question is whether my project setting was wrong or the way I uesd UIDatePicker was wrong. The crash

I solved it by forcing forceRightToLeft on each date picker sub views.

Try the following and it should work:

override func viewDidLayoutSubviews() {
    for currentView in datePicker.subviews {
        currentView.semanticContentAttribute = .forceRightToLeft
    }
} 

UIDatePicker CountDownTimer Localization Issues |Apple , I have a UIDatePicker of CountDownTimer mode and when my app in ://​stackoverflow.com/questions/35577317/uidatepicker-flips-on-ios9-rtl. I think this is problem with new font San Francisco (the font is big than Helvetica ) and .xib file. It can be hacked around by changing the UIDatePicker mode right before it was displayed, and then changing it back to the desired one:

In the AppDelegate.swift, enter the following code:

UIPickerView.appearance().semanticContentAttribute = .forceLeftToRight

UIDatePicker Flips on iOS9 RTL, Я думаю, что это побочный эффект вашей установки .ForceRightToLeft на UIView appearance прокси. Если это так, обратите внимание, что это не  3 UIDatePicker Flips on iOS9 RTL Feb 23 '16 3 ios 7 - Force view layout flip to RTL without language change Mar 9 '16 3 iOS Swift best practice on doing Right to Left(RTL) App May 13 '16

it's one of the subviews that caused the problem in this case. forcing left to right on all of the pickers subview will fix that for you.

How to support right-to-left languages, Hebrew, Arabic, Farsi, and more are all languages that use a Most images should be fine without flipping, but if you have images that point to  2 UIDatePicker Flips on iOS9 RTL Jun 9 '18. 2 UIButton not respect Aspect Fill contentMode after resizing animation Jul 1 '19. 0 Sort negative number string in iOS

You can force all UIDatePicker classes to be RTL from the AppDelegate.

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
    [[UIView appearanceWhenContainedIn:[UIDatePicker class], nil] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
}

Working with Internationalization and Localization in swift, Its better to use an arrow image to test flipping effect when we go from RTL To LTR in iOS9 the semantic changes as well depending on the language, but ! it​  Learn how to use UIDatePicker in iOS apps to allow users to select a date or time.

ios - UIDatePicker Flips på iOS9 RTL, Jeg tror dette er en bivirkning av innstillingene .ForceRightToLeft på UIView sin appearance fullmakt. Hvis det er tilfelle, vær oppmerksom på at dette ikke er en  iOS Tutorial - Date Picker View (UIDatePicker) for selecting and formatting date Maitrayee Ghosh. Loading Unsubscribe from Maitrayee Ghosh? Cancel Unsubscribe. Working

It seems like Apple's new feature of auto-flip interface on RTL languages cause problems when using UICollectionView. I used constraints of  He may input some invalid characters over there. Therefore, iOS SDK provides us a special class that enables us to choose a date from many options, and it is named UIDatePicker.

class UIDatePicker: UIControl Overview You can use a date picker to allow a user to enter either a point in time (calendar date, time value or both) or a time interval (for example for a timer).

Comments
  • add your selector method.
  • - (void)changeDate:(UIDatePicker *)sender { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"HH:mm"]; [dateFormatter setLocale:[NSLocale systemLocale]]; [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; NSString *capturedStartDate = [dateFormatter stringFromDate:sender.date]; if (sender.tag == startDayDP) { [_startDayHour setText:capturedStartDate]; } else { [_endDayHour setText:capturedStartDate]; } [self ReloadNotifications]; }
  • The ForceRightToLeft has no effect on the view. I have tried to remove it / change it, and nothing changed.
  • I'm not sure I understand. My question is: Are you calling this code anywhere? [UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft
  • Actually I'm using [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];' on my AppDelegate. But i have to use it, because i have some views that must be left to right.
  • This is not a supported configuration. If some views must be left-to-right, then you must set them individually on each view.
  • wakachamo RTL does not work for UIDatePicker when first time run the app.