当我在新的iOS7中编译我的应用程序时,我在进入UITableView的编辑模式时发现了一个问题。
当我按下红色减号按钮删除表格的一行时,该行向左缩进以显示“删除”按钮。但是,当此按钮出现时,单元格的文本会与editingAccesory 重叠(仅当文本长于单元格的长度时才会发生这种情况)。
如何消除重叠?
编辑:评论中的图像
编辑2: Tis是创建表的代码
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_tweetList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"SessionDetailCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Tweet *tweet = [_tweetList objectAtIndex:indexPath.row];
cell.textLabel.text = tweet.text;
return cell;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[tableView beginUpdates];
Tweet *deletedTweet = [_tweetList objectAtIndex:indexPath.row];
[_selectedSession removeTweetsObject:deletedTweet];
[deletedTweet deleteEntity];
_tweetList = [Tweet findAllSortedBy:@"index" ascending:YES withPredicate:[NSPredicate predicateWithFormat:@"session == %@",_selectedSession]];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
}
[[NSManagedObjectContext defaultContext]saveToPersistentStoreWithCompletion:nil];
}
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
selectedPath = indexPath;
[self performSegueWithIdentifier:@"EditTweet" sender:self];
}
解决方案:
最后,我将附件按钮置于默认状态,而我只使用编辑状态来删除行。这是我找到的唯一解决方案:(
或许,“willTransitionToState”方法可以帮助人们解决类似的问题。