启用&在扩展单元格中禁用UI工具栏 [英] Enabling & Disabling UI Toolbar in Expanded Cell

查看:90
本文介绍了启用&在扩展单元格中禁用UI工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单元格(videoCell),当取消选择高度为100px时,选中时将扩展为144px。在扩展的44​​像素中,我通过故事板放置了一个工具栏(detailToolbar)。

I have a cell (videoCell) that when unselected is 100px in height, and when selected expands to 144px. In the expanded 44 pixels I have placed a toolbar (detailToolbar) through storyboard.

现在这是我的问题。如果为工具栏启用了用户交互,则条形按钮可以工作,只需关闭单元格,我就可以点击单元格的原始100px中的任何一个。但是,当我试图扩展一个单元格时,问题就出现了。如果我点击未选定单元格的底部44px,则不会触发任何内容,但只有在选择前56个像素时才会响应。我假设单元格后面的detailToolbar阻止它工作。

Now here is my problem. If user interaction is enabled for the toolbar, the bar buttons work, and to simply close the cell I can just tap any of the original 100px of the cell. However, the problem arises when I'm attempting to expand a cell. If I tap the bottom 44px of the unselected cell, nothing is triggered, but will only respond if the top 56 pixels are selected. I'm assuming that the detailToolbar behind the cell is preventing it from working.

这是我的一些代码。我正在使用 Simon Lee的教程来扩展单元格。

Here's some my code. I'm using Simon Lee's tutorial to expand the cells.

- (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];
}


推荐答案

我自己已经回答了。我在Did Select Row方法中执行了以下操作:

I've answered it myself. I did the following in the Did Select Row method:

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

它完美无瑕!

这篇关于启用&在扩展单元格中禁用UI工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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