iphone - iOS : UITableView Reorder control not shown

标签 iphone ios uitableview

我正在设置所有必需的属性以在我的 iOS 应用程序中为 UITableView 实现重新排序控件,但是未显示重新排序控件。这是代码:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return 4;

}

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    cell.textLabel.text=[[NSString alloc]initWithFormat:@"Row %d", indexPath.row];
    cell.showsReorderControl=YES;
    return cell;
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}


-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView setEditing:YES animated:YES];
}


-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
         [tableView reloadData];
}

我已经实现了所有必需的方法。为什么不显示?

最佳答案

为此,您需要从一开始就设置 UITableView 的“编辑”属性。

希望对您有所帮助。

干杯!

关于iphone - iOS : UITableView Reorder control not shown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14576530/

相关文章:

iphone - 在 Xcode 3.1 中设置 gcov

iphone - 适用于 iPhone 应用程序的移动 OCR 引擎

iOS 9.1 UIScrollView 留下空白

ios - 无法在 UItableviewcell 中加载 collectionview

iphone - 为什么我在不同上下文中的对象之间得到 : Illegal attempt to establish a relationship . ..

iphone - 如何测试 UIButton 标题是否为 nil

ios - 使用 MKMapView 不带 map ,仅叠加

ios - Swift:在 iPhone 上启用 "dismiss keyboard"按钮?

swift - UITableViewCell 中的 UILabel 设置为固定行数时会占用额外空间

ios - 如何在uitableview中异步加载图像而不出现内存警告?