iphone - 在 iOS 7 中取消 UITableViewCell 滑动删除时收到通知

标签 iphone uitableview ios7 hidden

我正在使用 willTransitionToState,它会在显示右侧删除按钮时通知我。但是,当通过点击单元格区域之外取消删除时,不会调用此方法。我还尝试过 tableView:didEndEditingRowAtIndexPath。

答案在 this 中找到该问题在 iOS 7 中不起作用。

最佳答案

以下代码适用于 iOS 7(不适用于 iOS 6)。 iOS 6 解决方案是 this .

- (void)layoutSubviews
{
    [super layoutSubviews];

    [self detectDeleteButtonState];

    // it takes some time for delete button to disappear
    [self performSelector:@selector(detectDeleteButtonState) withObject:self afterDelay:1.0]; 
}

- (void)detectDeleteButtonState
{
    BOOL isDeleteButtonPresent = [self isDeleteButtonPresent:self.subviews];
    if (isDeleteButtonPresent) {
        NSLog(@"delete button is shown");
    } else {
        NSLog(@"delete button is gone");
    }
}

-(BOOL)isDeleteButtonPresent:(NSArray*)subviews
{
    for (UIView *subview in subviews)
    {
        if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"])
        {
           return [subview isHidden] == NO;
        }
        if([subview.subviews count] > 0){
           return [self isDeleteButtonPresent:subview.subviews];
        }
    }

    return NO;
}

关于iphone - 在 iOS 7 中取消 UITableViewCell 滑动删除时收到通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19036695/

相关文章:

objective-c - 如何在 objective-c 中将字节值转换为 int

iphone - 如果日期的年份已经过去,则将日期的年份增加一

ios - Storyboard iOS 4.2 中的递归 TableView

ios - 在哪里可以找到 Sprite Kit 可用的字体?

ios - 在后台接收和响应 EKEventStoreChangedNotification?

javascript - iPad 网络应用程序 : Detect Virtual Keyboard Using JavaScript in Safari?

iphone - 如何使用sql密码加密数据库

ios - 滚动 TableView 时获取 EXC_Bad_Access

ios - 从自定义 UITableViewCell 到带有数据的弹出 View 的 Segue 方式

ios - 如何自定义 UISlider 以使 stepps 可见