Search code examples
iphoneiosxcodedatepickerlandscape

UIDatePicker gets black in landscape on iPhone


I have UIDatePicker that in potrait mode lokes like this

Picker in potrait

And when spawn it or rotate to landscape it suddelny gets black like this

Picker in landscape

This problem occurs both if i first spawned the picker in landscape and when i rotate it to landscape. All in all as soon as the phone is in landscape the picker gets black. Picker is created as follows in viewDidAppear.

UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 200, 320, 216)];
[picker addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];  
[picker setDatePickerMode:UIDatePickerModeCountDownTimer];
[picker setMinuteInterval:5];
[self.view addSubview:picker];

The picker still works in landscape but the ugly black background for everything is not so pleasing for the eye. Any ideas of what the problem can be?


Solution

  • I had faced the same issue while trying to reset the frame of the date picker(countdown mode). Actually it wont support the frame resize. You can check the solution that i found here

    UIDatePicker in count down timer mode not supporting resizing?