Tôi vừa mới xem qua API mới này trên iOS8. Tuy nhiên, tôi không thể tìm thấy giải pháp nào nếu có thể sử dụng hình ảnh thay vì văn bản và cho phép vuốt sang trái và phải? Điều này thậm chí có thể? Việc triển khai duy nhất tôi đã tìm thấy là:iOS 8 UITableViewRowAction: Vuốt sang trái, ảnh?
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor blueColor];
UITableViewRowAction *moreAction2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button2" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
moreAction2.backgroundColor = [UIColor blueColor];
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];
return @[deleteAction, moreAction, moreAction2];
}
Cảm ơn bạn sir :-) – MichiZH
đây là một mẹo tuyệt vời, nhưng khi tôi thử nó, tôi nhận được một hình ảnh lát gạch. tôi có thể tạo hình ảnh cho kích thước của hàng, nhưng các ô của tôi có chiều cao thay đổi. nếu đó là trường hợp, có cách nào xung quanh nó hoặc tôi chỉ nên sử dụng một thư viện của bên thứ ba? – skinsfan00atg
Đối với những hình ảnh, tôi đặt cùng một CocoaPod mà sẽ cố gắng giải quyết điều này một cách tao nhã nhất có thể trong thời gian hiện tại: https://github.com/benguild/BGTableViewRowActionWithImage –