فهرست منبع

1.修改iOS Apex Mobile Detail地图只在Tracking分页显示,实现用户交互。

Pen Li 8 سال پیش
والد
کامیت
6ff0ce1812

+ 2 - 0
Apex Mobile/Apex Mobile/DetailPageViewController.h

@@ -25,4 +25,6 @@
 //@property bool showtabbar;
 //@property (strong, nonatomic) NSOperationQueue *webviewoprationQueue;
 
+@property (nonatomic,assign) BOOL showMap;
+
 @end

+ 51 - 0
Apex Mobile/Apex Mobile/DetailPageViewController.m

@@ -174,6 +174,43 @@
     
     UIBarButtonItem *previewMenuBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_menu"] style:UIBarButtonItemStylePlain target:self action:@selector(quickLookMenuClick:)];
     self.quickLook.navigationItem.rightBarButtonItem = previewMenuBtn;
+    
+    [self configureMap];
+}
+
+- (void)configureMap {
+    
+    if (!self.showMap) {
+        
+        NSArray *constraints = [[self.view constraints] mutableCopy];
+        // 删除Table与Map相关约束
+        for (NSLayoutConstraint *constaint in constraints) {
+            if ([constaint.identifier isEqualToString:@"top_constraint"]) {
+                [self.view removeConstraint:constaint];
+            } else if ([constaint.identifier isEqualToString:@"ratio_constraint"]) {
+                [self.view removeConstraint:constaint];
+            }
+        }
+        
+        // 移除地图
+        [self.shipMap removeFromSuperview];
+        self.shipMap = nil;
+        
+        // 设置新约束
+        NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:self.table
+                                                               attribute:NSLayoutAttributeTop
+                                                               relatedBy:NSLayoutRelationEqual
+                                                                  toItem:self.topLayoutGuide
+                                                               attribute:NSLayoutAttributeBottom
+                                                              multiplier:1.0
+                                                                constant:0];
+        [self.view addConstraint:top];
+        
+        
+        
+        [self.view layoutIfNeeded];
+    }
+    
 }
 
 - (void)saveDocumentClick:(id)sender {
@@ -1147,6 +1184,20 @@
     return nil;
 }
 
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
+    NSString* type =[segment valueForKey:@"_type"];
+    
+    if([type isEqualToString:@"tracking"]) {
+        NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
+        NSDictionary *location = [item objectForKey:@"location"];
+        [self.shipMap showShipAnnotaion:location];
+    }
+    
+    
+}
+
 #pragma mark - Quick Look
 
 - (MyQLPreviewController *)quickLook {

+ 2 - 0
Apex Mobile/Apex Mobile/DetailTabBarController.m

@@ -122,6 +122,8 @@
             [one.tabBarItem setTitlePositionAdjustment:offset];
 //            one.tabBarItem set
             
+            one.showMap = i == 0;
+            
             [controllers addObject:one];
         }
         

+ 2 - 2
Apex Mobile/Apex Mobile/Main.storyboard

@@ -1881,13 +1881,13 @@
                             <constraint firstItem="AKO-ni-aUG" firstAttribute="top" secondItem="mia-XC-A8d" secondAttribute="top" id="G9a-nI-Be8"/>
                             <constraint firstAttribute="trailing" secondItem="9wT-8n-8NB" secondAttribute="trailing" id="Hi5-QQ-eXP"/>
                             <constraint firstItem="AKO-ni-aUG" firstAttribute="centerX" secondItem="Sml-Qx-H9e" secondAttribute="centerX" id="QUs-dy-CCo"/>
-                            <constraint firstItem="mia-XC-A8d" firstAttribute="top" secondItem="9wT-8n-8NB" secondAttribute="bottom" constant="2" id="TXm-fF-9tV"/>
+                            <constraint firstItem="mia-XC-A8d" firstAttribute="top" secondItem="9wT-8n-8NB" secondAttribute="bottom" constant="2" identifier="top_constraint" id="TXm-fF-9tV"/>
                             <constraint firstItem="WfC-yf-L95" firstAttribute="top" secondItem="mia-XC-A8d" secondAttribute="bottom" id="VgT-0V-bY6"/>
                             <constraint firstItem="Cs2-5V-Ius" firstAttribute="centerY" secondItem="Sml-Qx-H9e" secondAttribute="centerY" id="b7w-Ch-uZo"/>
                             <constraint firstItem="9wT-8n-8NB" firstAttribute="top" secondItem="gd4-2b-xmy" secondAttribute="bottom" id="bmD-bG-2QS"/>
                             <constraint firstItem="mia-XC-A8d" firstAttribute="leading" secondItem="Sml-Qx-H9e" secondAttribute="leading" id="eJt-O9-kzA"/>
                             <constraint firstItem="9wT-8n-8NB" firstAttribute="leading" secondItem="Sml-Qx-H9e" secondAttribute="leading" id="rTT-vG-wDX"/>
-                            <constraint firstItem="mia-XC-A8d" firstAttribute="height" secondItem="9wT-8n-8NB" secondAttribute="height" multiplier="2:1" id="uWa-dk-e6q"/>
+                            <constraint firstItem="mia-XC-A8d" firstAttribute="height" secondItem="9wT-8n-8NB" secondAttribute="height" multiplier="2:1" identifier="ratio_constraint" id="uWa-dk-e6q"/>
                         </constraints>
                     </view>
                     <connections>

+ 2 - 0
Apex Mobile/Apex Mobile/RANetwork.m

@@ -1197,6 +1197,8 @@
     
 //    action=hand_new_home_list
     [params setObject:@"hand_new_home_list" forKey:@"action"];
+    [params setObject:@(YES) forKey:@"request_location"];
+    
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
     if(appDelegate.personalmode)
         params[@"personal_mode"] = @"true";

+ 26 - 0
Apex Mobile/Apex Mobile/ShipMap/AMShipMap.m

@@ -67,6 +67,31 @@ typedef enum {
     }
 }
 
+- (void)moveToLocation:(NSDictionary *)location {
+    if (location == nil) {
+        return;
+    }
+    
+    NSString *lonStr = [location valueForKey:@"lon"];
+    NSString *latStr = [location valueForKey:@"lat"];
+    if (lonStr && lonStr.length > 0 && latStr && latStr.length > 0) {
+        
+        double longitude = [lonStr doubleValue];
+        double latitude = [latStr doubleValue];
+        
+        CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
+        
+        MKCoordinateSpan span = MKCoordinateSpanMake(180, 360);
+        // 创建一个区域结构体变量
+        MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span);
+        
+        // 将大头针数据模型添加到MKMapView上管理
+        [self.mapView setRegion:region animated:YES];
+        
+    }
+    
+}
+
 - (void)showShipAnnotaion:(NSDictionary *)annotation {
     
     if (annotation == nil) {
@@ -111,6 +136,7 @@ typedef enum {
         if (self.showCurrent) {
             [self handleLoaction:current Priority:AMShipAnnotationPriorityRequired];
         }
+        [self moveToLocation:current];
     }
 }