2012-10-03 66 views
0

所有, 我在用的的UITableView,并试图实施编辑/删除功能。的UITableView编辑/ delate-单元格的内容超出屏幕

当我打电话给这条线。

[tblStoreAvail setEditing:TRUE animated:TRUE]; 

单元格的内容不在屏幕上。

这些功能从未被调用过。

- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath 

- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath 

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 

UITableView Cell content goes out of screen

+0

而不是将右标签作为子视图。将标签设置为accessoryView和EditingAccessoryView .. cell.editingAccessoryView = label; cell.accessoryView = label; – waheeda

回答

0

你得去上两个问题,泰穆尔。 1)你需要将表的“delegate”设置为保存这些委托方法的任何对象(可能是你的视图控制器)。您可以通过编程方式或通过XIB/Storyboard中的连接来执行此操作。 2)如果您使用自定义单元格,则需要调整字体大小以容纳要显示的所有数据。

如果您没有使用自定义UITableViewCell对象来显示表中的数据,那么就开始使用它们,以便获得您真正想要查看的格式。

1

如果您正在使用custuomTableViewCell实现以下方法与标签您所需的帧:

- (void)willTransitionToState:(UITableViewCellStateMask)state 
{ 
    [super willTransitionToState:state]; 
if(state == UITableViewCellStateDefaultMask) 
    { 
     [self.lblLocation setFrame:CGRectMake(13,22,302,21)]; 
    } 
    else if(state == UITableViewCellStateShowingDeleteConfirmationMask) 
    { 
     [self.lblLocation setFrame:CGRectMake(13,22,245,21)]; 
    } 
    else if(state == UITableViewCellStateShowingEditControlMask) 
    { 
     [self.lblLocation setFrame:CGRectMake(13,22,245,21)]; 
    } 
    else 
    { 
     [self.lblLocation setFrame:CGRectMake(13,22,210,21)]; 
    } 
} 

如果您使用的默认TableViewCell然后确保设置委托的tableView做象下面这样:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
yourCustomCell *cell = (yourCustomCell *)[tableView cellForRowAtIndexPath:indexPath]; 
[cell.lblLocation setFrame:CGRectMake(13,22,302,21)]; 
    return YES; 
}