//允许Menu菜单
-(BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath
{
returnYES;
}
//每个cell都可以点击出现Menu菜单
-(BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
returnYES;
}
-(void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
if (action ==@selector(copy:)) {
[UIPasteboardgeneralPasteboard].string = [arrayValueobjectAtIndex:indexPath.row];
}
if (action ==@selector(cut:)) {
[UIPasteboardgeneralPasteboard].string = [arrayValueobjectAtIndex:indexPath.row];
[arrayValuereplaceObjectAtIndex:indexPath.rowwithObject:@""];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationNone];
}
if (action ==@selector(paste:)) {
NSString *pasteString = [UIPasteboardgeneralPasteboard].string;
NSString *tmpString = [NSStringstringWithFormat:@"%@%@",[arrayValueobjectAtIndex:indexPath.row],pasteString];
[arrayValuereplaceObjectAtIndex:indexPath.rowwithObject:tmpString];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationNone];
}
}
效果如下图