【发布时间】:2012-12-14 10:54:30
【问题描述】:
我使用情节提要在我的视图中有一个UISegmentedControl,目前正在使用以下代码行以编程方式设置文本:
[segMonth setTitle:@"Month 1" forSegmentAtIndex:0];
[segMonth setTitle:@"Month 2" forSegmentAtIndex:1];
我还有一个使用此代码的日期函数,它获取当前月份的数字 (1-12):
// Date
NSDate *now = [NSDate date];
NSString *strDate = [[NSString alloc] initWithFormat:@"%@",now];
NSArray *arr = [strDate componentsSeparatedByString:@" "];
NSString *str;
str = [arr objectAtIndex:0];
NSArray *arr_my = [str componentsSeparatedByString:@"-"];
NSInteger month = [[arr_my objectAtIndex:1] intValue];
//End Date
我正在尝试将当前月份的第一段命名为“十二月”,将下个月的第二段命名为“一月”。
我尝试过使用以下代码,但它似乎不起作用:
[segMonth setTitle:@"%d" forSegmentAtIndex:0];
[segMonth setTitle:@"%d" forSegmentAtIndex:1];
显然,这也只会给出月份的数字,而不是名称..
【问题讨论】:
标签: ios xcode uisegmentedcontrol