2

내장 된 메일 앱과 매우 유사한 GUI로 RSS 리더를 구축 중입니다. 일단 Core Data가 다운로드되면 Core Data를 사용하여 정보를 저장합니다. 스토리가 다운로드되면 새로운 스토리임을 나타내는 파란색 점이 나타납니다. 스토리를 읽은 후 메인 페이지로 돌아 가면 점이 없어야합니다. 앱을 스크롤하거나 다시 시작하기 전까지는 그대로 있습니다. viewWillAppear: 메서드에서 모든 보이는 셀에 대해 cellForRowAtIndexPath:을 성공적으로 호출하는 [self.tableView reloadData];을 호출합니다. 여기 때해야 내 cellForRowAtIndexPath:iPhone 메일 앱에서 파란색 "읽지 않은 점"기능 다시 만들기

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"StoryCellIdentifier"; 
StoryCell *cell = (StoryCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) 
{ 
    cell = [[[NSBundle mainBundle] loadNibNamed:@"StoryCell" owner:self options:nil] objectAtIndex:0]; 
} 

NSUInteger thisRow = [indexPath row]; 
NSManagedObject *managedObject = [storyData objectAtIndex:thisRow]; 

cell.titleLabel.text = [[managedObject valueForKey:@"title"] description]; 
cell.descLabel.text = [[managedObject valueForKey:@"subTitle"] description]; 
if (!([managedObject valueForKey:@"new"])) 
{ 
    cell.readIndicator.image = nil; 
} 

return cell; 
} 

프로그램은 cell.readIndicator.image = nil; 라인 안타입니다. 실제로 프로그램은 점이 있거나 없을 때 동일한 실행 경로를 따릅니다. 또한 이것은 아마도 관련이 있지만 탐색 컨트롤러를 다시 클릭하면 내가 클릭 한 셀이 여전히 강조 표시됩니다.

편집 : .xib에 해당하는 .m 파일은 단지 상용구입니다.

EDIT2
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) 
    { } 
    return self; 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 
} 

: 셀에 대한

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath 
{ 
    StoryView *storyView = [[StoryView alloc] initWithNibName:@"StoryView" bundle:nil]; 
    NewsItem *item = [storyData objectAtIndex:[indexPath row]]; 

    [storyView viewLoaded:item]; 

// Pass the selected object to the new view controller. 
// ... 
    item.new = NO; 
    [managedObjectContext save:nil]; 
    [self.navigationController pushViewController:storyView animated:YES]; 

    [storyView release]; 
} 

답변

0

는 VC 터지는 때, 아마도 당신이 우리를 위해 사용자 정의 테이블 셀 코드의 관련 부분을 게시해야한다, 주요 문제에 대한 this

를 참조 강조 남아 봐.

1

벌써 별도의 버그가있는 한 가지는 이미 읽은 항목이있는 셀을 다시 읽지 않은 항목을 표시하는 데 사용하면 셀이 잘못 표시된다는 것입니다.

과 같은 작업을 수행해야합니다.
if (!([managedObject valueForKey:@"new"])) 
{ 
    cell.readIndicator.image = nil; 
} 
else 
{ 
    cell.readIndicator.image = blueDotImage; 
} 

셀을 만들 때 파란색 점 이미지를 놓았다 고 가정하는 것이 아니라.

비 표시 부분의 경우 setNeedsDisplay을 호출해야하는지 궁금합니다. readIndicator의 이미지를 변경하면 셀이 다시 그려야 함을 알 수 없습니다.

+0

어디에 setNeedsDisplay를 넣을까요? 그것이 될 것이라고 [셀 setNeedsDisplay]; 돌아 오기 바로 전에? 내 .xib에는 처음부터 파란색 점이 있습니다. 파란색 점으로 미리 설정되어 있지 않은 UIImageView가 있어야하나요? –

+0

[cell setNeedsDisplay] 또는 [cell.readIndicator setNeedsDisplay]가 도움이되는지 확실하지 않습니다. 파란색 점을 미리 채울 수 있습니다. 하나의 셀에는 도트가 사용되지 않지만 새로운 셀에는 도트가 필요한 경우에만 처리해야합니다. –

0

viewWillAppear 방법은 실행 중입니까? didSelectRowAtIndexPath 메소드에 [table reloadData] 문을 추가하고 올바르게 작동하는지 확인하십시오.

viewWillAppear 메서드가 항상 호출되지 않는 문제가있었습니다. 자세한 내용은 this thread을 확인하십시오.

+0

viewWillAppear가 실행 중이고 실행되면 cellForRowAtIndexPath를 통해 프로그램이 실행됩니다. –

+0

didSelectRowAtIndexPath 메서드의 코드를 붙여 넣을 수 있습니까? – Anurag

관련 문제