【发布时间】:2013-12-21 21:30:01
【问题描述】:
这是 Tapku 的方法,我想从控制器调用它
- (NSDate*) dateSelected{
if(selectedDay < 1 || selectedPortion != 1) return nil;
TKDateInformation info = [monthDate dateInformationWithTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
info.hour = 0;
info.minute = 0;
info.second = 0;
info.day = selectedDay;
NSDate *d = [NSDate dateFromDateInformation:info timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
return d;
}
我正在尝试这样调用它并将其转换为字符串格式。
TKCalendarMonthView *tk=[[TKCalendarMonthView alloc] init];
NSDate *date=tk.dateSelected;// How can I call it?With the debug it shows it's null.
NSDateFormatter *selectedDate=[[NSDateFormatter alloc] init];
[selectedDate setDateFormat:@"yyyy-MM-dd"];
NSMutableString *stringDate=[NSMutableString stringWithFormat:@"%@",[selectedDate stringFromDate: date]]`
【问题讨论】:
-
NSDate *date= [tk dateSelected];
-
这与 Xcode 无关。
-
您需要在您创建的
TKCalendarMonthView对象中为selectedDay和selectedPortion赋值。或者,您可以将值传递给函数。 -
那么,告诉我们,上面的日期是在哪里选择的?
-
您是否在调试模式下单步执行该方法?正在执行吗?
标签: objective-c tapku