【问题标题】:NSDateFormatter iOS6 issueNSDateFormatter iOS6 问题
【发布时间】:2012-10-28 19:11:31
【问题描述】:

我已经编写了 UIButton 按下以减少日期的代码。当前日期显示在 UILabel 文本属性中,并在按下按钮时更改为上一个日期。以下代码适用于 iOS5,但不适用于 iOS6。对于 iOS6,它给出的输出为 1999 年 12 月 31 日或 null。

- (IBAction)showPrevDate:(id)sender
{
   NSString *dateForDecrement = _showDateLbl.text;
   [dateFormatter setDateFormat:@"MMM d, yyyy (EEE)"];

   NSDate *dateObjectForDecrement = [dateFormatter dateFromString:dateForDecrement];

   int subtractDays = 1;

   dateAfterDecrement=[dateObjectForDecrement dateByAddingTimeInterval:-(24*60*60 * subtractDays)];

  _showDateLbl.text = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:dateAfterDecrement]];   
}

谁能验证一下,或者告诉我这是否是 iOS6 中的错误?

谢谢大家。

【问题讨论】:

  • 以后请注意格式化

标签: ios ios6 nsdateformatter


【解决方案1】:

我认为这是一个错误。我在 iOS 5 和 6 之间遇到了不同行为的相同问题。

看看这个:

http://openradar.appspot.com/12385667

http://openradar.appspot.com/12358210

也许你喜欢其中之一。

【讨论】:

  • 是的!这证实了我的怀疑。非常感谢。
  • 这个问题解决了吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-16
  • 1970-01-01
  • 2012-10-08
  • 2012-09-16
相关资源
最近更新 更多