我正在提供一个tableview,用户可以选择在哪个日历中放置一个事件。在iOS 5中,我使用新的EKCalendarChooser,但为了容纳那些不更新的人,我正在制作自己的日历存储器。无法获取日历标题
为了让我用这个手机上的日历:
- (void)viewDidLoad
{
[super viewDidLoad];
[self setWritableCalendars:[self getAllWritableCalendars]];
}
- (NSArray *)getAllWritableCalendars
{
EKEventStore *eventDB = [[EKEventStore alloc]init];
NSMutableArray *allCalendars = [NSMutableArray arrayWithArray:[eventDB calendars]];
NSPredicate *filter = [NSPredicate predicateWithFormat:@"allowsContentModifications == YES"];
[allCalendars filterUsingPredicate:filter];
NSArray *_writables = [NSArray arrayWithArray:allCalendars];
return _writables;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if ([[self writableCalendars] count] > 0)
{
cell.textLabel.text = [[[self writableCalendars] objectAtIndex:[indexPath row]] title];
}
else
{
cell.textLabel.text = @"No calendars found";
}
return cell;
}
的问题是,即使writableCalendars有两个目的,[[[自我writableCalendars] objectAtIndex:[indexPath行]标题]没有时间。该tableview呈现两个可点击但没有文本的单元格。
当我强制此代码在iOS 5中运行时,它工作正常,所有日历标题都显示出来。
我在这里错过了什么?
我试过了,标题都是零,在对象和'将允许修改'都没有。真奇怪。 – Cub71
你可以在建立对象的地方显示代码吗? –
writableCalendars是一个正常合成的数组属性。它建立在 - (NSArray *)getAllWritableCalendars方法中。 – Cub71