1

この動作は、連絡先アプリで確認できます。

連絡先ページのテーブル行を長押しすると、行の上部に「コピー」オプションがポップアップ表示されます。自分のテーブルビューセルでこの動作を取得するにはどうすればよいですか。

4

1 に答える 1

2

iOS 5.0以降を使用している場合は、デフォルトの動作を使用できます。

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

- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
    if (action == @selector(copy:)) {
        return YES;
    }    
    return NO;
}

- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
    if (action == @selector(copy:)) {
        [UIPasteboard generalPasteboard].string = @"test";
    }
}
于 2012-12-12T10:48:18.293 に答える