내장 된 메일 앱과 매우 유사한 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];
}
어디에 setNeedsDisplay를 넣을까요? 그것이 될 것이라고 [셀 setNeedsDisplay]; 돌아 오기 바로 전에? 내 .xib에는 처음부터 파란색 점이 있습니다. 파란색 점으로 미리 설정되어 있지 않은 UIImageView가 있어야하나요? –
[cell setNeedsDisplay] 또는 [cell.readIndicator setNeedsDisplay]가 도움이되는지 확실하지 않습니다. 파란색 점을 미리 채울 수 있습니다. 하나의 셀에는 도트가 사용되지 않지만 새로운 셀에는 도트가 필요한 경우에만 처리해야합니다. –