小编ugo*_*ino的帖子

在向左滑动的同时在UITableViewCell中自定义编辑视图.Objective-C或Swift

如何使用Objective C在iOS7 UITableView中制作自定义编辑视图,如Evernote或Apple Reminders应用程序,同时向左滑动.我试图设置自定义editingAccessoryView,但这不起作用.

Evernote编辑视图:

在此输入图像描述 提醒编辑视图:

在此输入图像描述

我目前的代码是

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        NSLog(@"delete");
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图用以下方法解决问题:(UITableViewController.h)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //make cell

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    [view setBackgroundColor:[UIColor greenColor]];
    //add Buttons to view

    cell.editingAccessoryView = view;

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

与之相同:(UITableViewCell)

- (void)willTransitionToState:(UITableViewCellStateMask)state;
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;
- (UIView*)editingAccessoryView;
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview swipe ios swift

73
推荐指数
6
解决办法
11万
查看次数

标签 统计

ios ×1

objective-c ×1

swift ×1

swipe ×1

uitableview ×1