我正在提供一個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