2 つのセクションを持つ次のコードがあります。3 つのセルを含む最初のセクションにはテキストがあり、2 番目のセクションにはテキストがありません。問題は、セクション 2 の 6 番目程度のセルの後、セルがセクション 1 のテキストを繰り返すことです。
したがって、私のセルは次のようになります。セクション 1 - プロファイル、連絡先、設定。セクション 2 - 空白 空白、空白、空白、空白、プロファイル、連絡先、設定。
私は何を間違っていますか?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(section == 0) return 3;
else return 9;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"LeftMenuCell";
UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(indexPath.section == 0) {
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"Profile";
break;
case 1:
cell.textLabel.text = @"Contacts";
break;
case 2:
cell.textLabel.text = @"Settings";
break;
default:
break;
}
} else {
//nothing should appear in these cells
}
return cell;
}