0
我在側邊菜單中有一些奇怪的行爲。下面是它應該是什麼樣子:側邊菜單中的UITableView單元格消失
我單擊該按鈕後,組織我使用此代碼的權利表現出一些更多的細胞
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
如果我從與菜單導航組織細胞顯示,然後再返回到菜單它顯示了這一點:
單元格顯示爲隱藏,但當我將單元格設置爲不隱藏時,如下所示: cell.hidden = NO; 它仍然顯示爲隱藏。
關於發生了什麼的任何想法?我的代碼中沒有任何地方將任何單元設置爲隱藏。
如果您需要更多代碼,請告訴我。
由於
下面是一些更多的代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"MenuCell";
MenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[MenuTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
if (indexPath.section == 0)
{
if (showOrgs && indexPath.row < organizations.count)
{
cell.label.text = [organizations objectAtIndex:indexPath.row];
cell.label.textColor = [UIColor whiteColor];
cell.leftImageView.hidden = YES;
cell.contentView.backgroundColor = [UIColor colorWithHex:@"#ff6b01" alpha:1.0];
cell.tag = 10002;
cell.leftButton.hidden = YES;
cell.righttButton.hidden = YES;
cell.leftButton.enabled = NO;
cell.righttButton.enabled = NO;
}
else if (showOrgs && indexPath.row >= organizations.count)
{
if (indexPath.row == organizations.count)
{
cell.label.text = [allUpper objectAtIndex:indexPath.row];//[organizations objectAtIndex:indexPath.row];
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.label.textColor = [UIColor blackColor];
cell.tag = 10001;
[cell.leftImageView setImage:[UIImage imageNamed:@"dashboard"]];
cell.leftImageView.hidden = NO;
}
else
{
cell.label.text = [allUpper objectAtIndex:indexPath.row];
cell.label.textColor = [UIColor blackColor];
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.tag = 10003;
if ([[allUpper objectAtIndex:indexPath.row] isEqualToString:@"All Media"])
{
cell.leftImageView.image = [UIImage imageNamed:@"image-btn"];
cell.leftImageView.hidden = NO;
}
}
}
NSLog(@"Row: %li", (long)indexPath.row);
if (!showOrgs && [[upperSection objectAtIndex:indexPath.row] isEqualToString:@"Dashboard"])
{
cell.label.text = [upperSection objectAtIndex:indexPath.row];//[organizations objectAtIndex:indexPath.row];
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.tag = 10001;
cell.hidden = NO;
[cell.leftImageView setImage:[UIImage imageNamed:@"dashboard"]];
}
else if (!showOrgs && [[upperSection objectAtIndex:indexPath.row] isEqualToString:@"All Media"])
{
cell.label.text = [upperSection objectAtIndex:indexPath.row];
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.tag = 10003;
cell.hidden = NO;
if ([[upperSection objectAtIndex:indexPath.row] isEqualToString:@"All Media"])
{
cell.leftImageView.image = [UIImage imageNamed:@"image-btn"];
}
}
}
// if (indexPath.section == 0 && showOrgs)
// cell.label.text = [organizations objectAtIndex:indexPath.row];
else if (indexPath.section == 1)
cell.label.text = [currentEvents objectAtIndex:indexPath.row];
else
cell.label.text = [allEvents objectAtIndex:indexPath.row];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0 && !showOrgs)
return upperSection.count;
else if (section == 0 && showOrgs)
return allUpper.count;
else if (section == 1)
return currentEvents.count;
else
return allEvents.count;
}
你可以添加一些代碼,使它更容易遵循?按下「組織」按鈕時會添加什麼單元格?什麼觸發菜單回到「正常」的方式? –
@RaphaelSilva我加了cellForRowAtIndex方法。我只是在數組中添加了一些硬編碼項目以添加到列表的頂部。當菜單關閉時,BOOL showOrgs設置爲no,然後我重新加載tableview – linuxer
你可以顯示你的'numberOfRowsInSection'方法嗎? – wottle