调用 setDatePickerMode 并将区域格式设置为台湾日历到日语时出现 UIDatePicker 异常

发布于 2024-11-05 15:32:12 字数 1696 浏览 2 评论 0原文

我们使用标准 UIDatePicker 视图来允许用户使用选择器设置倒计时持续时间。代码如下:

//in the header file
UIDatePicker *pickerView;

//in the implementation file, the error is thrown when this line executes
[self.pickerView setDatePickerMode:UIDatePickerModeCountDownTimer];

这在大多数情况下都可以正常工作,但是我们有一个用户将其区域格式设置为台湾,将日历设置为日语。然后出现以下异常:

2011-05-08 21:38:13.701 应用程序名称[6418:207] * 断言 -[UIDatePickerView 失败 _updateRowInColumn:toValue:withRepeatingAmount:元素:动画:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UIDatePicker.m:1499 2011-05-08 21:38:13.703 AppName[6418:207] 正在终止应用 由于未捕获的异常 'NSInternalInconsistencyException', 理由:‘哇!太多行 列:1' ** 第一次抛出时调用堆栈:( 0 CoreFoundation
0x00fa3be9 __异常预处理 + 185 1 libobjc.A.dylib
0x010f85c2 objc_异常_抛出 + 47 2 核心基础
0x00f5c628 +[NSException 引发:格式:参数:] + 136 3
基金会
0x000d447b-[NSAssertionHandler handleFailureInMethod:对象:文件:行号:描述:] + 116 4 UIKit 0x004b1e4e -[UIDatePickerView _updateRowInColumn:toValue:withRepeatingAmount:元素:动画:] + 695 5 UIKit 0x004b5254 -[UIDatePickerView _loadDateAnimated:] + 1012

有没有人有上述错误的经验或如何解决此问题?该组件的公历与非公历运算似乎存在问题。据我了解,如果未提供默认值,该组件将采用用户的设置:

来自 UIDatePicker.h:

@property(nonatomic,retain) NSLocale      *locale;                // default is nil. use current locale or locale from calendar
@property(nonatomic,retain) NSTimeZone    *timeZone;              // default is nil. use current time zone or time zone from calendar
@property(nonatomic,copy)   NSCalendar    *calendar;              // default is [NSCalendar currentCalendar]. setting nil returns to default

We are using the standard UIDatePicker view to allow the user to set a countdown duration using the picker. The code is as follows:

//in the header file
UIDatePicker *pickerView;

//in the implementation file, the error is thrown when this line executes
[self.pickerView setDatePickerMode:UIDatePickerModeCountDownTimer];

This works fine in most circumstances, however we have a user who has their region format set to Taiwan and their Calendar to Japanese. The following exception then occurs:

2011-05-08 21:38:13.701
AppName[6418:207] * Assertion
failure in -[UIDatePickerView
_updateRowInColumn:toValue:withRepeatingAmount:element:animated:],
/SourceCache/UIKit_Sim/UIKit-1447.6.4/UIDatePicker.m:1499
2011-05-08 21:38:13.703
AppName[6418:207]
Terminating app
due to uncaught exception
'NSInternalInconsistencyException',
reason: 'whoa! too many rows for
column: 1'
** Call stack at first throw: ( 0 CoreFoundation
0x00fa3be9 __exceptionPreprocess + 185
1 libobjc.A.dylib
0x010f85c2 objc_exception_throw + 47
2 CoreFoundation
0x00f5c628 +[NSException
raise:format:arguments:] + 136 3
Foundation
0x000d447b -[NSAssertionHandler
handleFailureInMethod:object:file:lineNumber:description:]
+ 116 4 UIKit 0x004b1e4e -[UIDatePickerView
_updateRowInColumn:toValue:withRepeatingAmount:element:animated:]
+ 695 5 UIKit 0x004b5254 -[UIDatePickerView
_loadDateAnimated:] + 1012

Does anyone have any experience with the above error or how to work around this? It seems like there is a problem with the Gregorian vs non Gregorian operation of this component. From what I understood the component takes the user's settings if no default is provided:

From UIDatePicker.h:

@property(nonatomic,retain) NSLocale      *locale;                // default is nil. use current locale or locale from calendar
@property(nonatomic,retain) NSTimeZone    *timeZone;              // default is nil. use current time zone or time zone from calendar
@property(nonatomic,copy)   NSCalendar    *calendar;              // default is [NSCalendar currentCalendar]. setting nil returns to default

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

燃情 2024-11-12 15:32:12

您是否为实例变量 pickerView 创建了属性?由于您没有在问题中提到它,我想知道您如何访问 pickerView 的 setter 方法而不创建像 @property(nonatomic, keep) UIDatePicker *pickerView; 这样的属性

have you created a property for your instance variable pickerView? Since you have not mentioned it in the question, I am wondering how you are accessing the setter methods for the pickerView without creating a property like @property(nonatomic, retain) UIDatePicker *pickerView;

月隐月明月朦胧 2024-11-12 15:32:12

这之前是一个错误,现在随着 iOS 5 的发布得到了解决。

This was previously a bug which is now resolved with the release of iOS 5.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文