Я написал tableViewController и установил в раскадровке, как и во всех учебниках. Теперь я создал очень простой массив с 31 элементом, но результатом является то, что показано только 15 элементов, даже если количество массивов возвращает правильное количество элементов. Вот простой код.UITableView всегда показывает 15 строк
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
myArray = [[NSArray alloc] initWithObjects:@"5:10 am", @"5:45 am", @"6:45 am", @"7:10 am",
@"7:30 am", @"7:45 am", @"8:00 am", @"8:15 am",
@"8:30 am", @"9:05 am", @"9:40 am", @"10:15 am",
@"10:45 am", @"11:15 am", @"11:45 am", @"12:15 pm",
@"12:45 pm", @"1:15 pm", @"1:45 pm", @"2:15 pm", @"2:45 pm",
@"3:15 pm", @"3:45 pm", @"4:15 pm", @"5:20 pm", @"6:20 pm",
@"7:15 pm", @"8:15 pm", @"9:15 pm", @"10:15 pm", @"11:15 pm", nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [myArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
cell.textLabel.text = [myArray objectAtIndex:indexPath.row];
cell.detailTextLabel.text = @"foo";
// Configure the cell...
return cell;
}
Даже если я установить количество строк вручную до 4, например, я вижу строк с правильным элементом массива, но 11 пустых строк ... в общей сложности раз 15 строк. Любая идея?
пс: Похоже, что только «1» страницы отображается в симуляторе IOS ... как нет прокрутки не возможно, но массив наверняка пополнится всеми элементами ...
Что происходит в '- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section'? Можете ли вы установить точку останова и распечатать значение '[myArray count]'? – Romain
В первом случае прокрутите вниз. Второй случай, это не ошибка. В обоих случаях вы можете справиться с настройкой высоты строк, которые вам нужно увидеть на экране. –
[myArray count] возвращает правильный номер ... но похоже, что в iOS-симуляторе отображается только одна страница ... – yorh