Я застрял на этой проблеме в течение нескольких дней, и я не смог понять это ..... Я создал свой проект из шаблона на основе навигации, и он автоматически сгенерировал просмотр таблицы.Затем я добавил несколько разделов и несколько строк и попытался заполнить строки таблицы простыми строками.Все работает нормально, пока не будет определенного количества разделов и строк, таблица достигает определенной длины.Содержимое первой строки также появляется в последних двух строках, и я понятия не имею, почему ... Пожалуйста, ПОМОГИТЕ !!!Вот мой код:
#import "RootViewController.h"
@implementation RootViewController
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release anything that can be recreated in viewDidLoad or on demand.
// e.g. self.myOutlet = nil;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 5;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if (indexPath.section == 0) {
if (indexPath.row == 0) {
cell.textLabel.text = @"test";
}
}
return cell;
}
- (void)dealloc {
[super dealloc];
}
@end
ОБНОВЛЕНИЕ:
Хорошо, так что я думаю, что получил, но я понятия не имею, что на самом деле происходило, это было просто совпадение, но когда я изменил строку:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
до:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
это сработало ...
Может кто-нибудь, пожалуйста, объясните мне это ????; -)