iphone - UITableView 幻灯片不可编辑行与可编辑行 Xcode iPhone

标签 iphone objective-c ios xcode uitableview

我正在开发一款 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/

相关文章:

ios - 如何用原生键盘替换 UIPickerView?

php - Windows 服务器推送通知 iOS 的 APNS 问题

iphone - 在 Objective-C 中将 TypeDef 作为参数

iphone - iOS动态行宽

iphone - UITableViewCell 文本标签偏移量

iphone - 如何在更改另一个 View Controller 中的值后要求第一个 View Controller 重新加载其 View ?

ios - 如何在 C 函数中触发 NSTimer

ios - 企业应用程序未安装在iPhone 5s上

iphone - iOS AVAudioPlayer OSStatus 错误-43

ios - CoreData 一次又一次地向数据库中添加数据