- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
[cell setBackgroundColor:[UIColor lightGrayColor]];
cell.textLabel.textColor = [UIColor lightTextColor];
cell.textLabel.backgroundColor = nil;
cell.detailTextLabel.textColor = [UIColor darkGrayColor];
cell.detailTextLabel.backgroundColor = nil;
// Get list of local notifications
NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row];
// Display notification info
[cell.textLabel setText:notif.alertBody];
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"MMM dd 'at' HH:mm"];
NSString *dateString = [format stringFromDate:notif.fireDate];
NSString *textData = [[NSString alloc]initWithFormat:@"%@",dateString];
[cell.detailTextLabel setText:textData];
//[notif.fireDate description]
[self.tableView reloadData];
return cell;
}
모든 것을 아주 이상한 문제는 내가 쓰기 해달라고하면 absoloutely 정상 간다 "[self.tableView reloadData]은,"나는한다면합니다 (셀이 있지만이 표시되지처럼, 그러나 보인다 셀 분리자는 테이블 뷰의 셀 수에 따라 사라집니다.아이폰 OS -있는 tableView realodData
사용자가 뷰를 벗어나서 뷰를 다시로드하여 업데이트 된 정보를 표시 할 필요가 없도록 reloadData를 사용해야합니다.
의견이 있으십니까? 당신은 cellForRowAtIndexPath
내부 [self.tableView reloadData];
를 추가 할 필요가없는
Omar가 말했듯이 이것은 데이터를 다시로드하는 잘못된 장소입니다. 'newItem' 메쏘드를 만들고 거기에'[tableView reloadData]'를 대신하십시오. 또는 항목을 제거/지울 때. – Hassan
예를 들어 주시겠습니까? –
'reloadData'는 테이블 뷰에게 컨트롤러에서 데이터를 다시 불러 오도록 지시하는 데에만 사용됩니다 (즉, 위에서 게시 한 것과 같은 일부 대리자 메소드가 호출 됨). 아직이 기능이 없다면 [this] (http://www.iphonesdkarticles.com/2009/01/uitableview-creating-simple-table-view.html)을보십시오. – Hassan