首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSDateFormatter iOS6问题

NSDateFormatter iOS6问题
EN

Stack Overflow用户
提问于 2012-10-28 18:40:44
回答 1查看 231关注 0票数 0

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

代码语言:javascript
复制
- (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中的bug?

谢谢你们。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-28 18:51:00

我觉得这是个窃听器。我在iOS 5和6之间遇到了同样的问题,表现不同。

看看这个:

http://openradar.appspot.com/12385667

http://openradar.appspot.com/12358210

也许你喜欢其中的一个。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13108110

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档