本文介绍了自定义editingAccessoryView表现不可预测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,首先关闭 - 我希望我的单元格在编辑模式下看到我的UItableView(带有一些更好的按钮):

Okay, first off - how I want my cells to look in my UItableView in editing mode (with some nicer buttons):

然而 - 这就是它现在的样子:

However - this is how it looks right now:

我的问题是我的自定义EditingAccessoryView只出现在我最初创建的单元格上,并且出现了那些圆形的东西(那些叫做什么?)。哪个做得不好。

My problem is that my custom EditingAccessoryView only appears on the cell that I first created, and that those circle-thingies (what are those called?) appears. Which doesn't do much good.

现在,我的代码看起来像这样(这似乎是执行此操作的常用方法,例如在此问题中看到:)

Now, my code looks like this (which seems like the common way of doing this, seen at this question for example: How to add Custom EditingAccessoryView for UITableView?)

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        cell.editingAccessoryView = AccessoryView;
        AccessoryView.backgroundColor = [UIColor clearColor];
    }

我读过你应该可以通过以下方式调用自定义的editAccessoryView滑动,即使 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 返回NO。然而,这一点我无法实现。

I have read that you are supposed to be able to call your custom editingAccessoryView by swiping, even if - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath returns "NO". This however I have not been able to achieve.

所以,总结一下upp;我希望我的editingAccessoryView显示在所有单元格中 - 如果可能,请删除红色圆圈。或者,或者,当我滑动时调用我的editingAccessoryView - 当用户执行此操作时调用哪种方法?

So, to sum it upp; I want my editingAccessoryView to be displayed at all cells - and, if possible, remove the red circle. Or, alternatively, call my editingAccessoryView when I swipe - what method gets called when the user does this?

任何帮助都将非常感谢。

Any help would be much appreciated.

推荐答案

我建议您继承表格单元格并覆盖以下方法

I suggest you subclass table cell and override following method

- (void)layoutSubviews
{
    if([self isEditing])
    {
        // your custom stuff
       [self.contentView addSubview:myButton];
    }
}

这篇关于自定义editingAccessoryView表现不可预测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 10:47