简体   繁体   English

未在 iPhone 6/6+ 上触发 UIDatePicker "Value Changed" 操作

[英]UIDatePicker "Value Changed" action not triggered on iPhone 6/6+

I noticed an unusual behavior with the UIDatePicker.我注意到 UIDatePicker 的异常行为。

I have a table, when I select a cell the datePicker come up.我有一个表格,当我选择一个单元格时,datePicker 就会出现。

When I change the value inside the picker, on iPhone 4s/5/5s (iOS 8) the "value changed" action is triggered as expected.当我更改选择器内的值时,在 iPhone 4s/5/5s (iOS 8) 上,“值更改”操作按预期触发。

On iPhone 6/6+, the first time nothing happen (neither exception nor anything).在 iPhone 6/6+ 上,第一次什么都没有发生(既没有例外也没有任何事情)。 After changing the value a second time, it works.第二次更改该值后,它起作用了。

So, my question is simple...why on iPhone 6/6+ has this behavior?所以,我的问题很简单……为什么在 iPhone 6/6+ 上有这种行为?

Is it a known bug or what?这是一个已知的错误还是什么?

Thank you谢谢

Update:更新:

My app is in the store since August 2012 and has always worked properly...我的应用程序自 2012 年 8 月以来一直在商店中,并且一直运行正常......

Here's the code这是代码

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    // set the selected HH:mm date
    self.pickerView.date = [[self.fetchedResultsController objectAtIndexPath:indexPath] presence];    
    // check if our date picker is already on screen
    if (self.pickerViewView.superview == nil && self.duplicateDatePickerView.superview == nil)
    {
        [self openDatePickerView:self.pickerViewView withToolbar:self.toolBar];
    }
    self.selectedPresence = [self.fetchedResultsController objectAtIndexPath:indexPath];
}

- (IBAction)dateAction:(id)sender{
    NSIndexPath *indexPath = self.ipForDateAction;
    if(!self.selectedPresence)
        self.selectedPresence = [self.fetchedResultsController objectAtIndexPath:indexPath];
    NSDateComponents *comp = [TimeUtility hoursAndMinutesFromDate:self.pickerView.date];
    self.selectedPresence.presence = [TimeUtility date:self.selectedPresence.presence withHour:comp.hour minute:comp.minute];

    [self saveContext];
    [self timeRemainingForDate];
}

Update 2:更新 2:

This strange behavior happens only setting the picker's mode to "Count Down Timer"这种奇怪的行为只发生在将选择器的模式设置为“倒数计时器”

Here is a workaround for this bug.这是此错误的解决方法。 I already filed a radar to Apple and they say they are aware of this issue.我已经向 Apple 提交了一份雷达报告,他们说他们知道这个问题。 This answer is provided by the user Sergio Silva that kindly answers me on the Apple developer forum:此答案由用户 Sergio Silva 在 Apple 开发者论坛上亲切地回答我提供:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self.myDatePicker setCountDownDuration: xxxxxx];




 //or [self.myDatePicker setDate:xxxx animated:NO];
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM