NSDateFormatter iOS6问题
我已经为UIButton press编写了一个减量日期代码。当前日期显示在UILabel文本属性中,当按下按钮时,它将更改为上一个日期。下面的代码在iOS5中运行得非常好,但在iOS6中不起作用。对于iOS6,它给出的输出为1999年12月31日或nullNSDateFormatter iOS6问题,ios,ios6,nsdateformatter,Ios,Ios6,Nsdateformatter,我已经为UIButton press编写了一个减量日期代码。当前日期显示在UILabel文本属性中,当按下按钮时,它将更改为上一个日期。下面的代码在iOS5中运行得非常好,但在iOS6中不起作用。对于iOS6,它给出的输出为1999年12月31日或null - (IBAction)showPrevDate:(id)sender { NSString *dateForDecrement = _showDateLbl.text; [dateFormatter setDateFormat:
- (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吗
谢谢各位。我想这是个bug。我在iOS 5和iOS 6之间遇到了相同的问题,但行为不同 看看这个:
也许你正陷入其中。请注意以后的格式设置。是的!这证实了我的怀疑。非常感谢。这个问题已经解决了吗?