查找用户是否更喜欢12/24小时时钟? [英] Find if user prefers 12 / 24 Hour Clock?

查看:89
本文介绍了查找用户是否更喜欢12/24小时时钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个drawRect,它使时间轴有点像iCal。我使用for循环沿滚动视图写入时间。我想知道A)是否是一种确定用户是否在系统设置中选择了12或24小时时钟的方法,以及B)是否有更有效的方式来更改时间标签,然后每次通过调用'if'查询'for'循环。
干杯

I've got a drawRect that makes a timeline a bit like iCal. I use a for loop to write the times along a scroll view. I was wondering if A) theres a way of determining whether the user has chosen a 12 or 24 hour clock in the system settings and B) if there is a more efficient way of changing the time labels then calling an 'if' query every pass of the 'for' loop. Cheers

推荐答案

NSDate *today = [NSDate date];
NSString *formattedString = [NSDateFormatter localizedStringFromDate:today dateStyle: kCFDateFormatterNoStyle timeStyle: kCFDateFormatterShortStyle];

NSRange foundRange;
foundRange = [formattedString rangeOfString:"am" options:NSCaseInsensitiveSearch];
if(foundRange.location == NSNotFound) {
    foundRange = [formattedString rangeOfString:"pm" options:NSCaseInsensitiveSearch];
}

BOOL isAMPMSettingOn = (foundRange.location != NSNotFound);

这篇关于查找用户是否更喜欢12/24小时时钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆