RADetailActionSelectionViewController+TableDelegate.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // RADetailActionSelectionViewController+TableDelegate.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/4.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RADetailActionSelectionViewController+TableDelegate.h"
  9. #import "RADetailActionSelectionModel.h"
  10. @implementation RADetailActionSelectionViewController (TableDelegate)
  11. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  12. return 44.0f;
  13. }
  14. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  15. RADetailActionSelectionModel *model = [self.actions objectAtIndex:indexPath.row];
  16. if (indexPath.row != 0) {
  17. RADetailActionSelectionModel *currentModel = [self.actions objectAtIndex:0];
  18. NSString *msg = [NSString localizedStringWithFormat:NSLocalizedString(@"the %@ is not done,are you sure to update %@ now?", nil),currentModel.actionTitle,model.actionTitle];
  19. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) message:msg preferredStyle:UIAlertControllerStyleAlert];
  20. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  21. }];
  22. UIAlertAction *sureAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  23. [self dismissForAction:model];
  24. }];
  25. [alertVC addAction:cancelAction];
  26. [alertVC addAction:sureAction];
  27. [self presentViewController:alertVC animated:YES completion:nil];
  28. } else {
  29. [self dismissForAction:model];
  30. }
  31. }
  32. - (void)dismissForAction:(RADetailActionSelectionModel *)action {
  33. [self dismissViewControllerAnimated:NO completion:^{
  34. if (self.delegate && [self.delegate respondsToSelector:@selector(detailSelectAction:)]) {
  35. [self.delegate detailSelectAction:action];
  36. }
  37. }];
  38. }
  39. @end