ios8 UITableVIewCell 側滑顯示多個按鈕


-(NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
                                                                         title:@"刪除"
                                                                       handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
                                                                           NSLog(@"刪除");
                                                                       }];
    UITableViewRowAction *rowActionSec = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
                                                                            title:@"標記"
                                                                          handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
                                                                              NSLog(@"標記");
                                                                          }];
    rowActionSec.backgroundColor = [UIColor greenColor];
    NSArray *arr = @[rowAction,rowActionSec];
    return arr;
}

block里面是點擊方法 , 這個委托是ios8之后的才有,如果項目只適配ios8以上就可以不用自己寫按鈕了。返回值是 UITableViewRowAction 的數組

UITableViewRowAction 的大小自動根據文字適配


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM