У меня есть объект Parser
, который содержит 15 элементов из Интернета (статей).Содержимое UITableViewCell теряется при прокрутке
Я пытаюсь загрузить эти товары в свои TableView
. Моя проблема в том, что у меня есть 8 элементов, видимых при запуске (4-дюймовый симулятор сетчатки), но когда он начинает прокрутку, почти все мое содержимое потеряно, и я не вижу остальных 7 предметов. Не уверен, что я делаю неправильно, это мой код:
- (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;
}
Edit:
Это то, что он показывает при прокрутке, если я вхожу данные перед возвратом ячейки внутри cellRowAtIndexPath
:
2013-09-29 13:37:05.341 Inter[3685:a0b] Article for index: 0 . Title: Cagliari-Inter, tutte le curiosità
; date: (null) .
2013-09-29 13:37:05.343 Inter[3685:a0b] Article for index: 1 . Title: Cerrone "Oggi abbiamo vinto da squadra"
; date: (null) .
2013-09-29 13:37:05.344 Inter[3685:a0b] Article for index: 2 . Title: Le immagini del 10° "Memorial Prisco"
; date: (null) .
2013-09-29 13:37:05.345 Inter[3685:a0b] Article for index: 3 . Title: Primavera, Udinese-Inter 0-1
; date: (null) .
2013-09-29 13:37:05.345 Inter[3685:a0b] Article for index: 4 . Title: Tutte le immagini della vigilia di Cagliari-Inter
; date: (null) .
2013-09-29 13:37:05.346 Inter[3685:a0b] Article for index: 5 . Title: Udinese-Inter Primavera, 0-0 a fine primo tempo
; date: (null) .
2013-09-29 13:37:05.347 Inter[3685:a0b] Article for index: 6 . Title: Mazzarri "Rischio buccia di banana in un momento di euforia"
; date: (null) .
2013-09-29 13:37:05.348 Inter[3685:a0b] Article for index: 7 . Title: Inter Campus in Bosnia Erzegovina: passi avanti per i progetti a Sarajevo e Domanovici
; date: (null) .
2013-09-29 13:37:11.053 Inter[3685:a0b] Article for index: 8 . Title: (null) ; date: (null) .
2013-09-29 13:37:28.181 Inter[3685:a0b] Article for index: 9 . Title: (null) ; date: (null) .
2013-09-29 13:37:29.499 Inter[3685:a0b] Article for index: 10 . Title: (null) ; date: (null) .
2013-09-29 13:37:29.591 Inter[3685:a0b] Article for index: 11 . Title: (null) ; date: (null) .
2013-09-29 13:37:35.642 Inter[3685:a0b] Article for index: 1 . Title: (null) ; date: (null) .
2013-09-29 13:37:35.767 Inter[3685:a0b] Article for index: 0 . Title: (null) ; date: (null) .
Редакция:
Полный код here.
Вы инициализируете название и дату в своей пользовательской ячейке? или вы просто подключаете их из раскадровки? – null
Нет, я просто подключаю их из раскадровки. – Kobe
Странно, что когда я прокручиваю, все мои элементы из массива элементов становятся нулевыми. – Kobe