Sunday, 29 September 2013

UITableViewCell contents are lost when scrolling

UITableViewCell contents are lost when scrolling

I have a Parser object that contains 15 items from the internet
(articles). I am trying to load this items in my TableView. My problem is
that I have 8 items visible at start (4 inch retina simulator) but when
start scrolling, almost all my contents are lost and I can not see the
rest of the 7 items. Not sure what I am doing wrong, this is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
parser = [[Parser alloc] init];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [[parser items] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ArticleCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"ArticleCell"];
Article *article = [parser items][indexPath.row];
cell.title.text = article.title;
cell.date.text = article.date;
return cell;
}

No comments:

Post a Comment