From 5cc82ad652d53e14839360e4ac31a1281e6340c0 Mon Sep 17 00:00:00 2001
From: coderyi <coderyi@163.com>
Date: Mon, 26 Sep 2016 00:45:35 +0800
Subject: [PATCH] you can remove map path

---
 .../NEHTTPEyeDetailViewController.m           | 14 +++++-----
 NetworkEye/NetworkEye/NEMapViewController.m   | 26 +++++++++++++------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/NetworkEye/NetworkEye/NEHTTPEyeDetailViewController.m b/NetworkEye/NetworkEye/NEHTTPEyeDetailViewController.m
index df52b84..6db5634 100644
--- a/NetworkEye/NetworkEye/NEHTTPEyeDetailViewController.m
+++ b/NetworkEye/NetworkEye/NEHTTPEyeDetailViewController.m
@@ -42,13 +42,13 @@ - (void)viewDidLoad {
     [backBt addTarget:self action:@selector(backBtAction) forControlEvents:UIControlEventTouchUpInside];
     [bar addSubview:backBt];
     
-    UIButton *settingsBt=[UIButton buttonWithType:UIButtonTypeCustom];
-    settingsBt.frame=CGRectMake([[UIScreen mainScreen] bounds].size.width-60, 27, 50, 30);
-    [settingsBt setTitle:@"map" forState:UIControlStateNormal];
-    settingsBt.titleLabel.font=[UIFont systemFontOfSize:13];
-    [settingsBt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
-    [settingsBt addTarget:self action:@selector(rightAction) forControlEvents:UIControlEventTouchUpInside];
-    [bar addSubview:settingsBt];
+    UIButton *mapBt=[UIButton buttonWithType:UIButtonTypeCustom];
+    mapBt.frame=CGRectMake([[UIScreen mainScreen] bounds].size.width-60, 27, 50, 30);
+    [mapBt setTitle:@"map" forState:UIControlStateNormal];
+    mapBt.titleLabel.font=[UIFont systemFontOfSize:13];
+    [mapBt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [mapBt addTarget:self action:@selector(rightAction) forControlEvents:UIControlEventTouchUpInside];
+    [bar addSubview:mapBt];
     
     UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(([[UIScreen mainScreen] bounds].size.width-230)/2, 20, 230, 44)];
     titleText.backgroundColor = [UIColor clearColor];
diff --git a/NetworkEye/NetworkEye/NEMapViewController.m b/NetworkEye/NetworkEye/NEMapViewController.m
index 4165211..24d9685 100644
--- a/NetworkEye/NetworkEye/NEMapViewController.m
+++ b/NetworkEye/NetworkEye/NEMapViewController.m
@@ -41,6 +41,17 @@ - (void)viewDidLoad {
     [backBt addTarget:self action:@selector(backBtAction) forControlEvents:UIControlEventTouchUpInside];
     [bar addSubview:backBt];
     
+    UIButton *deleteBt=[UIButton buttonWithType:UIButtonTypeCustom];
+    deleteBt.frame=CGRectMake([[UIScreen mainScreen] bounds].size.width-60, 27, 50, 30);
+    [deleteBt setTitle:@"delete" forState:UIControlStateNormal];
+    deleteBt.titleLabel.font=[UIFont systemFontOfSize:13];
+    [deleteBt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [deleteBt addTarget:self action:@selector(rightAction) forControlEvents:UIControlEventTouchUpInside];
+    if (_model.mapJSONData.length>0) {
+        [bar addSubview:deleteBt];
+    }
+    
+    
     UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(([[UIScreen mainScreen] bounds].size.width-230)/2, 20, 230, 44)];
     titleText.backgroundColor = [UIColor clearColor];
     titleText.textColor=[UIColor whiteColor];
@@ -54,25 +65,20 @@ - (void)viewDidLoad {
     }else {
         requestPath = [_model.requestURLString substringToIndex:requestPathRange.location];
     }
+    _model.mapPath = requestPath ;
     titleText.text=requestPath;
     titleText.lineBreakMode = NSLineBreakByTruncatingHead;
     
     mainTextView=[[UITextView alloc] initWithFrame:CGRectMake(0, 64, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height-64)];
     [self.view addSubview:mainTextView];
     mainTextView.text=_model.mapJSONData;
+    
 }
 
 - (void)backBtAction {
     if (![[mainTextView.text stringByTrimmingCharactersInSet:
           [NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqualToString:_model.mapJSONData]) {
-        NSRange requestPathRange = [_model.requestURLString rangeOfString:@"?"];
-        NSString *requestPath;
-        if (requestPathRange.location == NSNotFound) {
-            requestPath =_model.requestURLString;
-        }else {
-            requestPath = [_model.requestURLString substringToIndex:requestPathRange.location];
-        }
-        _model.mapPath = requestPath ; 
+
         _model.mapJSONData = [mainTextView.text stringByTrimmingCharactersInSet:
                                                  [NSCharacterSet whitespaceAndNewlineCharacterSet]];
         [[NEHTTPModelManager defaultManager] addMapObject:_model];
@@ -82,5 +88,9 @@ - (void)backBtAction {
     
 }
 
+- (void)rightAction {
+    [[NEHTTPModelManager defaultManager] removeMapObject:_model];
+}
+
 
 @end