13 iphone
我的视图中有一个UIDatePicker.
我在时间模式下设置了DatePicker.
因此用户只能选择时间.
无论用户选择何种时间都应显示在文本框中.
我不知道如何显示时间值 - 由用户通过DatePicker - 时间模式设置.
请帮我..
pix*_*x0r 37
您需要使用NSDateFormatter
格式化NSDate
您的返回UIDatePicker
.这里有一些未经测试的示例代码,假设您将UILabel作为属性"myLabel",将UIDatePicker作为属性"myDatePicker":
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"h:mm a"];
self.myLabel.text = [outputFormatter stringFromDate:self.myDatePicker.date];
[outputFormatter release];
Run Code Online (Sandbox Code Playgroud)
您需要检查Unicode Locale Data Markup Language页面上的日期格式模式.该字符串"h:mm a"
将为您提供类似于"12:08 PM"
您的语言环境的内容.
归档时间: |
|
查看次数: |
20336 次 |
最近记录: |