不会触发commitEditingStyle

oni*_*ivi 9 uitableview ios

我有一个UITableView,我试图在编辑模式处于活动状态时删除一行,但不会触发commitEditingStyle.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }

    cell.text=[NSString stringWithFormat:@"Row Number %d",indexPath.row];

    return cell;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"trying to delete a row..");
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}

-(void)Edit:(id)sender //Active editing mode
{
    [self.table setEditing:YES animated:YES];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(Done:)];
}
Run Code Online (Sandbox Code Playgroud)

我只是想删除一行?

这是我展示我的popover的方式:

UIPopoverController *popover;
-(IBAction)open:(id)sender
{
    CGRect r=((UIButton*)sender).frame;
    CGRect tRect=[((UIButton*)sender) convertRect:((UIButton*)sender).frame toView:self.view];
    tRect.origin.x=r.origin.x;

    Popover *firstViewCtrl = [[Popover alloc] init];

    UINavigationController *navbar = [[UINavigationController alloc] initWithRootViewController:firstViewCtrl];
    navbar.preferredContentSize = CGSizeMake(300, 300);
    popover = [[UIPopoverController alloc] initWithContentViewController:navbar];
    popover.delegate = self;
    popover.popoverContentSize = CGSizeMake(300, 300);

    CGRect popRect = CGRectMake(0,
                                0,
                                200,
                                200);

    [popover presentPopoverFromRect:popRect
     inView:self.view
     permittedArrowDirections:UIPopoverArrowDirectionAny
     animated:YES];

   // [popover presentPopoverFromRect:tRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

我使用Xcode接口创建了UITableView.

-(void)Done:(id)sender
{
    [self.table setEditing:NO animated:NO];
    //[self.table endEditing:true];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(Edit:)];
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

amo*_*one 8

当你触摸它触发删除按钮,而不是减...和删除按钮在你的tableview不显示propably因您的tableview的宽度......