我正在设置所有必需的属性以在我的 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/