lable에 날짜를 인쇄해야합니다. 날짜가 데이터베이스에서 올바르게 표시됩니다. 문제는 데이터베이스 날짜를 현재 날짜와 비교해야합니다. 데이터베이스 날짜가 현재 날짜보다 작 으면 lable은 "Due"라는 문자열을 출력해야합니다. 그렇지 않으면 다음과 같이 날짜를 인쇄하십시오 : 03/05/2012. 난 내의 tableview를 스크롤 할 때 난 내 사용자 정의 셀 수업 시간에 뭐하는 거지 이 코드는 내가 다음 값은 내가 잘못 변화가 나에게아이폰에서 재사용 가능한 셀을 제어하는 방법
- (void) updateContent: (Tasksmodal*) taskobject{
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/yyyy"];
NSString* duedate = [dateFormat stringFromDate:taskobject.DueDate];
NSDate *currentdate;
currentdate=[NSDate date];
//NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init];
//[dateFormat1 setDateFormat:@"dd/MM/yyyy"];
NSString* duedate1 = [dateFormat stringFromDate:currentdate];
if ([currentdate compare:taskobject.DueDate]!=NSOrderedDescending) {
[email protected]"Due";
DateLable.textColor=[UIColor redColor];
}
도와주세요입니다 내가 컨트롤러 클래스를 전달할 방법이 코드를 writenelse{
DateLable.text=duedate;
DateLable.textColor=[UIColor blackColor];
}
}
내 컨트롤러 클래스에 .m // 표보기 셀 모양을 사용자 지정합니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TasksList * cell =(TasksList*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[TasksList alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
//[[[cell contentView] subviews] makeObjectsPerformSelector: @selector(removeFromSuperview)];
taskobject=(Tasksmodal*)[self.lstTasks objectAtIndex:indexPath.row];
[cell updateContent:taskobject];
return cell;
}
Rocky가 'ARC'를 사용하고 있다면 누출되지는 않지만 dateformatter를 재사용하는 것이 좋습니다. – rckoenes
ssteinberg하지만 내 테이블 셀을 스크롤 할 때 셀이 재사용되고 있습니다. 그러면 가치가 예정대로 변경됩니다. 03/05/2012 이유가 무엇입니까? – Rocky
셀 관리가 잘못되어 나머지 방법을 게시합니다. – ssteinberg