iOS9: UIDatePicker with datePickerMode of UIDatePickerModeTime only shows Hours, and no Minutes

后端 未结 6 1187
天命终不由人
天命终不由人 2021-02-14 07:39

I\'m using Xcode beta 7 with the iOS9 simulator. Using a UIDatePicker with a datePickerMode of UIDatePickerModeTime only shows Hours, and not minutes.

See screenshot:

6条回答
  •  失恋的感觉
    2021-02-14 07:58

    I had an issue when upgrading Xcode to 7.0.

    When the UIDatePicker was displayed the middle portion was blank, as per LordParsley's answer.

    The height of the UIDatePicker for iOS 9 is 216; whereas earlier versions the height is 162, and forcing the height to 162 resolved the issue.

    Since my view is defined within a storyboard, I setup a height constraint on the UIDatePicker and set the height to 162 for iOS versions < 9.0, within the view's viewDidLoad.

    - (void) viewDidLoad {
        [super viewDidLoad];
    
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0) {
            //
            // NOTE: iOS 9, or Xcode 7, now sets UIDatePicker height at 216; whereas,
            // iOS 8, or Xcode 6.x, set it at 162.
            //
            // If the height is left at 216, then on iOS 7.1, the middle portion of the
            // UIDatePicker control is missing.  Setting the hieght to 162 fixes the issue
            // within this application.
            //
            // UIDatePicker frame cannot be used to adjust the size, therefore use a
            // height contraint to change the size.
            //
            self.dateHeightConstraint.constant = 162;
        }
    }
    

提交回复
热议问题