// // RADetailActionSelectionViewController+TableDelegate.m // Apex And Drivers // // Created by Jack on 2018/6/4. // Copyright © 2018年 USAI. All rights reserved. // #import "RADetailActionSelectionViewController+TableDelegate.h" #import "RADetailActionSelectionModel.h" @implementation RADetailActionSelectionViewController (TableDelegate) - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 44.0f; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { RADetailActionSelectionModel *model = [self.actions objectAtIndex:indexPath.row]; if (indexPath.row != 0) { RADetailActionSelectionModel *currentModel = [self.actions objectAtIndex:0]; NSString *msg = [NSString localizedStringWithFormat:NSLocalizedString(@"the %@ is not done,are you sure to update %@ now?", nil),currentModel.actionTitle,model.actionTitle]; UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) message:msg preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; UIAlertAction *sureAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [self dismissForAction:model]; }]; [alertVC addAction:cancelAction]; [alertVC addAction:sureAction]; [self presentViewController:alertVC animated:YES completion:nil]; } else { [self dismissForAction:model]; } } - (void)dismissForAction:(RADetailActionSelectionModel *)action { [self dismissViewControllerAnimated:NO completion:^{ if (self.delegate && [self.delegate respondsToSelector:@selector(detailSelectAction:)]) { [self.delegate detailSelectAction:action]; } }]; } @end