Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将日期改为个位数_Ios_Objective C_View_Nsdate_Nsdateformatter - Fatal编程技术网

Ios 将日期改为个位数

Ios 将日期改为个位数,ios,objective-c,view,nsdate,nsdateformatter,Ios,Objective C,View,Nsdate,Nsdateformatter,我正在开发一个应用程序,我有以下代码: NSDateFormatter *clockFormat = [[NSDateFormatter alloc]init]; [clockFormat setDateFormat:@"hh:mm a"]; self.clockLabel.text = [clockFormat stringFromDate:[NSDate date]]; [self performSelector:@selector(updateClockLabel) withObject:

我正在开发一个应用程序,我有以下代码:

NSDateFormatter *clockFormat = [[NSDateFormatter alloc]init];
[clockFormat setDateFormat:@"hh:mm a"];
self.clockLabel.text = [clockFormat stringFromDate:[NSDate date]];
[self performSelector:@selector(updateClockLabel) withObject:self afterDelay:1.0];
我创建了一个带有子视图的视图,以创建LCD类型的时钟显示,并希望隐藏与时钟标签对应的正确子视图。我创建了每个视图的数组(数字),现在我如何告诉视图,如果hh:mm中的第一个h为1,则隐藏这些子视图以在视图中生成LCD“1”


简单地说,如何访问hh:mm的每个数字?

您可以使用NSRange获取子字符串。使用
NSRangeMake(位置、长度)
。获取
self.clockLabel.text
的第一个字符的NSString。你可以说

NSString *firstHourDigit = [self.clockLabel.text substringWithRange:NSRangeMake(0,1)];
请看答案: