فهرست منبع

1.修改iOS Apex Driver Detail打开地图标题显示。

Pen Li 7 سال پیش
والد
کامیت
a3f7748a39

+ 9 - 1
Redant Drivers/Apex And Drivers/Detail/Cell/RADetailMapCell.h

@@ -8,9 +8,17 @@
 
 #import <UIKit/UIKit.h>
 
-@class RADetailMapModel;
+@class RADetailMapModel, RADetailMapCell;
+
+@protocol RADetailMapCellDelegate <NSObject>
+
+- (void)mapCell:(RADetailMapCell *)cell clickMapButtonWithModel:(RADetailMapModel *)model;
+
+@end
+
 @interface RADetailMapCell : UITableViewCell
 
 @property (nonatomic,strong) RADetailMapModel *model;
+@property (nonatomic,weak) id<RADetailMapCellDelegate> delegate;
 
 @end

+ 3 - 8
Redant Drivers/Apex And Drivers/Detail/Cell/RADetailMapCell.m

@@ -87,14 +87,9 @@
     
 //    MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
     
-    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([self.model.lat doubleValue], [self.model.lon doubleValue]);
-    
-    MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate
-                                                                                       addressDictionary:nil]];
-    toLocation.name = self.model.title;
-    [MKMapItem openMapsWithItems:@[toLocation] launchOptions:@{
-                                                               MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:coordinate]
-                                                               }];
+    if (self.delegate && [self.delegate respondsToSelector:@selector(mapCell:clickMapButtonWithModel:)]) {
+        [self.delegate mapCell:self clickMapButtonWithModel:self.model];
+    }
     
 }
 

+ 2 - 1
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.h

@@ -12,8 +12,9 @@
 #import "RADetailPhotoCell.h"
 #import "RADetailSignatureCell.h"
 #import "RADetailActionSelectionViewController.h"
+#import "RADetailMapCell.h"
 
 
-@interface RAOrderDetailViewController (TableViewDataSource) <UITableViewDataSource,RADetailLocationCellDelegate,RAdetailActionsCellDelegate,UIPopoverPresentationControllerDelegate,RADetailActionSelectionDelegate,RADetailSignatureCellDelegate,RADetailPhotoCellDelegate>
+@interface RAOrderDetailViewController (TableViewDataSource) <UITableViewDataSource,RADetailLocationCellDelegate,RAdetailActionsCellDelegate,UIPopoverPresentationControllerDelegate,RADetailActionSelectionDelegate,RADetailSignatureCellDelegate,RADetailPhotoCellDelegate,RADetailMapCellDelegate>
 
 @end

+ 30 - 1
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -29,7 +29,7 @@
 
 #import <AddressBook/AddressBook.h>
 //#import <Contacts/Contacts.h>
-#import "RADetailMapCell.h"
+
 #import "RADetailPhotoModel.h"
 #import "RADetailMapModel.h"
 
@@ -78,6 +78,7 @@
             RADetailMapCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RADetailMapCell" forIndexPath:indexPath];
             RADetailMapModel *mapModel = (RADetailMapModel *)model;
             [cell setModel:mapModel];
+            cell.delegate = self;
             return cell;
         }
             break;
@@ -114,6 +115,34 @@
     return [self sectionNumber];
 }
 
+#pragma mark - Map
+
+- (void)openMapWithTitle:(NSString *)title model:(RADetailMapModel *)model {
+    
+    if (model == nil) {
+        return;
+    }
+    
+    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([model.lat doubleValue], [model.lon doubleValue]);
+    
+    MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate
+                                                                                       addressDictionary:nil]];
+    toLocation.name = title;
+    [MKMapItem openMapsWithItems:@[toLocation] launchOptions:@{
+                                                               MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:coordinate]
+                                                               }];
+    
+}
+
+- (void)mapCell:(RADetailMapCell *)cell clickMapButtonWithModel:(RADetailMapModel *)model {
+    
+    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
+    
+    NSString *title = [self titleForSection:indexPath.section];
+    
+    [self openMapWithTitle:title model:model];
+}
+
 #pragma mark - Photo/Signature
 
 - (void)previewImage:(UIImage *)img {

+ 2 - 0
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController.h

@@ -16,6 +16,8 @@
 @property (nonatomic,copy) NSString *orderType2;
 @property (nonatomic,copy) NSString *status_no;
 
+@property (nonatomic,strong,readonly) UITableView *tableView;
+
 - (NSInteger)sectionNumber;
 - (NSString *)titleForSection:(NSInteger)section;
 - (NSInteger)numberOfItemForSection:(NSInteger)section;

+ 4 - 0
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController.m

@@ -252,6 +252,10 @@
 
 #pragma mark - Getter
 
+- (UITableView *)tableView {
+    return self.detailTableView;
+}
+
 - (NSMutableArray *)sectionArray {
     if (!_sectionArray) {
         _sectionArray = [NSMutableArray array];