Что я хочу: отобразить некоторый список данных в виде таблицы.Tableview с пустыми ячейками
Данные хранятся внутри одного массива путем создания разных объектов. Поэтому для каждого объекта размер массива изменяется. Поэтому моя проблема заключается в показе данных. Вместо того, чтобы полностью заполнять ячейки таблицы, некоторые ячейки остаются пустыми. Это не выглядит хорошо.
Может ли кто-нибудь объяснить, как получить представление таблицы без лишних пустых ячеек?
Вот как я организовать данные:
Recipe *recipe1 = [Recipe new];
recipe1.ingredients = [NSArray arrayWithObjects:@"1. Fish - 500 g .",@"2. Onion (Big) - 2 nos (Chopped)",@"3. Garlic (Chopped) - 3 flakes",@"4. Green chillies - 2 nos (Chopped)",@"5. Chilly powder - 3/4 tbsp ",@"6. Coriander powder - 1/2 tsp ",nil];
Recipe *recipe2 = [Recipe new];
recipe2.ingredients = [NSArray arrayWithObjects:@"1. fish - 300 gm",@"2. Tomato(medium) - 1 no",@"3. Garlic - 10 gm",@"4. Coconut powder - 10 gm",@"5. Curry leaves - A few",@"6. Salt - As reqd",@"7. Onions(medium) - 2 nos(chopped)",@"8. Oil - 1 - 2 tbsp",nil];
Я хочу, чтобы показать этот список ингредиентов внутри TableView в зависимости от того, какого блюда выбрано.
Вот мои методы источника данных
- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CellIdentifier";
// Dequeue or create a cell of the appropriate type.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryNone;
}
[cell.textLabel setFont:[UIFont fontWithName:@"Bold" size:20]];
// Configure the cell.
cell.textLabel.text =[data objectAtIndex:indexPath.row];
return cell;
}
будет у поста метод TableView Datasource? –