无法将可扩展单元格中的uitoolbar隐藏起来 [英] Can not get uitoolbar in expandable cell to hide

查看:78
本文介绍了无法将可扩展单元格中的uitoolbar隐藏起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我现在正在使用 Simon Lee的精彩教程扩展我的细胞。一切都很好。

Hello I am currently using Simon Lee's wonderful tutorial to expand my cells. Everything is working fine.

我的单元格是100px,扩展后单元格变为144px高。在添加的44px中,我放置了一个带有条形按钮的工具栏。我已经让按钮工作但有一个问题。

My cells are 100px, and when expanded the cell becomes 144px high. In the added 44px I have placed a toolbar with bar buttons. I've gotten the buttons to work but there is one problem.

当细胞扩展时,我可以点击100px中的任何一个并关闭细胞,但是当细胞关闭时关闭,点击单元格的较低44px导致栏按钮完成其动作。我假设它仍然启用,如果隐藏在网站上。

When the cell is expanded I can tap any of the 100px and the cell closes, however when the cell is closed , tapping on the lower 44px of the cell causes the bar buttons to fulfill their actions. I'm assuming that it's still enabled if when hidden from site.

我已经在故事板中禁用了用户交互但是在选择单元格时无法启用它反之亦然!如果有人能指出我正确的方向,那就行​​了!

I have disabled user interaction in storyboard but can not get it to turn on when cell is selected and vice versa! If anyone could point me in the right direction that would work!

西蒙说了一些关于做以下事情的事情,但我不确定在哪里准确实施它!我到处试过了!

Simon said something about doing the following, but I'm not quite sure on where to exactly implement it! I've tried it everywhere!

for(NewsCell *cell in [self.tableView visibleCells]) {
    BOOL cellIsSelected = [selectedIndexes objectForKey:indexPath];
    [cell.detailToolbar setUserInteractionEnabled:cellIsSelected];
}

这是我的一些代码:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
// If our cell is selected, return double height

if([self cellIsSelected:indexPath]) {

return 144.0;

}

// Cell isn't selected so return single height

return 100.0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath
{

// Deselect
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];

self.tableView.clipsToBounds = YES;


// Store cell 'selected' state keyed on indexPath
NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected];
[selectedIndexes setObject:selectedIndex forKey:indexPath]; 

// This is where magic happens...
[self.tableView beginUpdates];
 [self.tableView endUpdates];
}


推荐答案

我在我身上找到了它拥有。事实证明,我所要做的就是将我单元格中的用户交互设置为关闭。并为所选单元格打开它。

I figured it out on my own. It turns out that all I had to do was set the user interaction in my cell to off. and switch it on for the selected cell.

for(NewsCell *cell in [self.tableView visibleCells]) {
        BOOL cellIsSelected = isSelected;
        [cell.detailToolbar setUserInteractionEnabled:cellIsSelected];
}

这篇关于无法将可扩展单元格中的uitoolbar隐藏起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆