我正在开发一款 iPhone 应用程序,但遇到了一个问题。我有一个带有一些可编辑行的 UITableView(
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{ )
和一个不可编辑的行。如果我点击编辑,可编辑的行向右滑动一点,左边有一个红色的圆形按钮,但不可编辑的行根本不滑动。有没有办法也将它向右滑动但没有左侧的红色按钮?目前看起来不太好。我希望有人可以帮助我:)
最佳答案
我不确定更改 tableView 的默认行为是否是个好主意。 但如果你真的想要,你可以例如使用缩进。
// Might be target of button
- (void) setEditingMode
{
tableView.editing = YES;
[tableView reloadData];
}
// Might be target of button
- (void) resetEditingMode
{
tableView.editing = NO;
[tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = ...;
....
Boolean cellIsEditable = ...;
if( tableView.editing && !cellIsEditable )
{
cell.indentationWidth = ...; // (please experiment to find the exact value)
cell.indentationLevel = 1;
}
else
{
cell.indentationLevel = 0;
}
}
关于iphone - UITableView 幻灯片不可编辑行与可编辑行 Xcode iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9083552/