diff --git a/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb b/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb index 6a0d451..56a3b0e 100644 Binary files a/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb and b/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb differ diff --git a/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-shm b/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-shm index 3a520c0..b6a30c1 100644 Binary files a/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-shm and b/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-shm differ diff --git a/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-wal b/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-wal index cfda9e8..2ed1fef 100644 Binary files a/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-wal and b/DerivedData/MPSE/Index/Debug/iphonesimulator10.2-x86_64/MPSE.xcindex/db.xcindexdb-wal differ diff --git a/MPSE.xcodeproj/project.pbxproj b/MPSE.xcodeproj/project.pbxproj index f425ded..30bfea9 100644 --- a/MPSE.xcodeproj/project.pbxproj +++ b/MPSE.xcodeproj/project.pbxproj @@ -15,6 +15,13 @@ 070A8D0D1E389EAE00EA67A3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 070A8D0B1E389EAE00EA67A3 /* LaunchScreen.storyboard */; }; 070A8D181E389EAE00EA67A3 /* MPSETests.m in Sources */ = {isa = PBXBuildFile; fileRef = 070A8D171E389EAE00EA67A3 /* MPSETests.m */; }; 070A8D231E389EAE00EA67A3 /* MPSEUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 070A8D221E389EAE00EA67A3 /* MPSEUITests.m */; }; + 070A8D331E38A96D00EA67A3 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 070A8D321E38A96D00EA67A3 /* CoreLocation.framework */; }; + 070A8D351E38B73A00EA67A3 /* Map.m in Sources */ = {isa = PBXBuildFile; fileRef = 070A8D341E38B73A00EA67A3 /* Map.m */; }; + 070A8D381E38B96D00EA67A3 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 070A8D371E38B96D00EA67A3 /* MapKit.framework */; }; + 0768B3651E39A9CD0063CC0A /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = 0768B3641E39A9CD0063CC0A /* User.m */; }; + 07F817A71E3A210700EDEC0E /* ME.png in Resources */ = {isa = PBXBuildFile; fileRef = 07F817A61E3A210700EDEC0E /* ME.png */; }; + 07F817AB1E3A226500EDEC0E /* PointType.png in Resources */ = {isa = PBXBuildFile; fileRef = 07F817AA1E3A226500EDEC0E /* PointType.png */; }; + 07F817AD1E3A22E500EDEC0E /* PointType.ico in Resources */ = {isa = PBXBuildFile; fileRef = 07F817AC1E3A22E500EDEC0E /* PointType.ico */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -51,6 +58,16 @@ 070A8D1E1E389EAE00EA67A3 /* MPSEUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MPSEUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 070A8D221E389EAE00EA67A3 /* MPSEUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPSEUITests.m; sourceTree = ""; }; 070A8D241E389EAE00EA67A3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 070A8D321E38A96D00EA67A3 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + 070A8D341E38B73A00EA67A3 /* Map.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Map.m; sourceTree = ""; }; + 070A8D361E38B74400EA67A3 /* Map.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Map.h; sourceTree = ""; }; + 070A8D371E38B96D00EA67A3 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; + 0768B3621E39A9AA0063CC0A /* User.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = ""; }; + 0768B3641E39A9CD0063CC0A /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = ""; }; + 07F817A61E3A210700EDEC0E /* ME.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ME.png; sourceTree = ""; }; + 07F817AA1E3A226500EDEC0E /* PointType.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = PointType.png; sourceTree = ""; }; + 07F817AC1E3A22E500EDEC0E /* PointType.ico */ = {isa = PBXFileReference; lastKnownFileType = image.ico; path = PointType.ico; sourceTree = ""; }; + 07F817AE1E3A50F800EDEC0E /* Post.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Post.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,6 +75,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 070A8D381E38B96D00EA67A3 /* MapKit.framework in Frameworks */, + 070A8D331E38A96D00EA67A3 /* CoreLocation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -85,6 +104,7 @@ 070A8D161E389EAE00EA67A3 /* MPSETests */, 070A8D211E389EAE00EA67A3 /* MPSEUITests */, 070A8CFB1E389EAD00EA67A3 /* Products */, + 070A8D311E38A96D00EA67A3 /* Frameworks */, ); sourceTree = ""; }; @@ -101,6 +121,8 @@ 070A8CFC1E389EAD00EA67A3 /* MPSE */ = { isa = PBXGroup; children = ( + 0768B3631E39A9AF0063CC0A /* User */, + 070A8D301E38A54900EA67A3 /* Map */, 070A8D001E389EAD00EA67A3 /* AppDelegate.h */, 070A8D011E389EAD00EA67A3 /* AppDelegate.m */, 070A8D031E389EAD00EA67A3 /* ViewController.h */, @@ -117,6 +139,9 @@ 070A8CFD1E389EAD00EA67A3 /* Supporting Files */ = { isa = PBXGroup; children = ( + 07F817A61E3A210700EDEC0E /* ME.png */, + 07F817AC1E3A22E500EDEC0E /* PointType.ico */, + 07F817AA1E3A226500EDEC0E /* PointType.png */, 070A8CFE1E389EAD00EA67A3 /* main.m */, ); name = "Supporting Files"; @@ -140,6 +165,34 @@ path = MPSEUITests; sourceTree = ""; }; + 070A8D301E38A54900EA67A3 /* Map */ = { + isa = PBXGroup; + children = ( + 070A8D341E38B73A00EA67A3 /* Map.m */, + 070A8D361E38B74400EA67A3 /* Map.h */, + ); + name = Map; + sourceTree = ""; + }; + 070A8D311E38A96D00EA67A3 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 070A8D371E38B96D00EA67A3 /* MapKit.framework */, + 070A8D321E38A96D00EA67A3 /* CoreLocation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 0768B3631E39A9AF0063CC0A /* User */ = { + isa = PBXGroup; + children = ( + 07F817AE1E3A50F800EDEC0E /* Post.h */, + 0768B3621E39A9AA0063CC0A /* User.h */, + 0768B3641E39A9CD0063CC0A /* User.m */, + ); + name = User; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -246,9 +299,12 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 07F817A71E3A210700EDEC0E /* ME.png in Resources */, 070A8D0D1E389EAE00EA67A3 /* LaunchScreen.storyboard in Resources */, 070A8D0A1E389EAE00EA67A3 /* Assets.xcassets in Resources */, 070A8D081E389EAD00EA67A3 /* Main.storyboard in Resources */, + 07F817AB1E3A226500EDEC0E /* PointType.png in Resources */, + 07F817AD1E3A22E500EDEC0E /* PointType.ico in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -273,8 +329,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0768B3651E39A9CD0063CC0A /* User.m in Sources */, 070A8D051E389EAD00EA67A3 /* ViewController.m in Sources */, 070A8D021E389EAD00EA67A3 /* AppDelegate.m in Sources */, + 070A8D351E38B73A00EA67A3 /* Map.m in Sources */, 070A8CFF1E389EAD00EA67A3 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -505,6 +563,7 @@ 070A8D291E389EAE00EA67A3 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 070A8D2A1E389EAE00EA67A3 /* Build configuration list for PBXNativeTarget "MPSETests" */ = { isa = XCConfigurationList; @@ -513,6 +572,7 @@ 070A8D2C1E389EAE00EA67A3 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 070A8D2D1E389EAE00EA67A3 /* Build configuration list for PBXNativeTarget "MPSEUITests" */ = { isa = XCConfigurationList; @@ -521,6 +581,7 @@ 070A8D2F1E389EAE00EA67A3 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/MPSE.xcodeproj/xcuserdata/Eric.xcuserdatad/xcschemes/MPSE.xcscheme b/MPSE.xcodeproj/xcuserdata/Eric.xcuserdatad/xcschemes/MPSE.xcscheme index b422b1d..1185c22 100644 --- a/MPSE.xcodeproj/xcuserdata/Eric.xcuserdatad/xcschemes/MPSE.xcscheme +++ b/MPSE.xcodeproj/xcuserdata/Eric.xcuserdatad/xcschemes/MPSE.xcscheme @@ -5,6 +5,22 @@ + + + + + + + + + + + + + + + + + + @@ -26,6 +71,16 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> + + + + @@ -35,6 +90,16 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> + + + + diff --git a/MPSE/AppDelegate.m b/MPSE/AppDelegate.m index 471f35e..7c92d21 100644 --- a/MPSE/AppDelegate.m +++ b/MPSE/AppDelegate.m @@ -7,6 +7,7 @@ // #import "AppDelegate.h" +#import "User.h" @interface AppDelegate () @@ -17,6 +18,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. + return YES; } diff --git a/MPSE/Assets.xcassets/AppIcon.appiconset/Contents.json b/MPSE/Assets.xcassets/AppIcon.appiconset/Contents.json index 118c98f..b8236c6 100644 --- a/MPSE/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/MPSE/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", diff --git a/MPSE/Base.lproj/Main.storyboard b/MPSE/Base.lproj/Main.storyboard index 4529698..139336d 100644 --- a/MPSE/Base.lproj/Main.storyboard +++ b/MPSE/Base.lproj/Main.storyboard @@ -1,14 +1,18 @@ - + + + + - + + - + @@ -16,11 +20,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MPSE/Info.plist b/MPSE/Info.plist index 38e98af..e82f85a 100644 --- a/MPSE/Info.plist +++ b/MPSE/Info.plist @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion en + NSLocationWhenInUseUsageDescription + 我们想获取你的现在的位置 CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/MPSE/ME.png b/MPSE/ME.png new file mode 100644 index 0000000..0a1f9fb Binary files /dev/null and b/MPSE/ME.png differ diff --git a/MPSE/Map.h b/MPSE/Map.h new file mode 100644 index 0000000..112c255 --- /dev/null +++ b/MPSE/Map.h @@ -0,0 +1,15 @@ +// +// Map.h +// MPSE +// +// Created by Saturneric on 17/1/25. +// Copyright © 2017年 Bakantu Eric. All rights reserved. +// +#import +#import +#import + +@interface MapDelegate : UIViewController + + +@end diff --git a/MPSE/Map.m b/MPSE/Map.m new file mode 100644 index 0000000..e599681 --- /dev/null +++ b/MPSE/Map.m @@ -0,0 +1,128 @@ +// +// Map.m +// MPSE +// +// Created by Saturneric on 17/1/25. +// Copyright © 2017年 Bakantu Eric. All rights reserved. +// + +#import "Map.h" +#import "Post.h" + +@interface MapDelegate(){ + UIImage * UserImagine; + UIImage * PointImagine; + NSString * UserID; + NSString * PostID; +} + + +@property (weak, nonatomic) IBOutlet MKMapView *MapNear; +@property (strong, nonatomic) MKPointAnnotation *AnnotationPointTarget; +@property (nonatomic) CLLocationCoordinate2D MyLocationNow; + +@end + +@implementation MapDelegate + +@synthesize MapNear = _MapNear; +@synthesize AnnotationPointTarget = _AnnotationPointTarget; +@synthesize MyLocationNow = _MyLocationNow; + + +-(void)viewDidLoad{ + [super viewDidLoad]; + _MapNear.delegate = self; + + _MapNear.scrollEnabled = YES; + _MapNear.zoomEnabled = YES; + _MapNear.rotateEnabled = YES; + + _MapNear.showsBuildings = YES; + _MapNear.userTrackingMode = MKUserTrackingModeFollow; + _MapNear.showsUserLocation = YES; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MapAddAnnotation:) name:@"MapAddTarget" object:nil]; + + + _MyLocationNow = CLLocationCoordinate2DMake(39.547,116.2317); + _MapNear.region = MKCoordinateRegionMake(_MyLocationNow, MKCoordinateSpanMake(0.006, 0.006)); + MKMapCamera *MySeeCamera = [MKMapCamera cameraLookingAtCenterCoordinate:_MyLocationNow fromEyeCoordinate:_MyLocationNow eyeAltitude:20000 ]; + _MapNear.camera = MySeeCamera; + + + PointImagine = [UIImage imageNamed:@"PointType.ico"]; +} + +-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{ + self.MyLocationNow = userLocation.coordinate; + _MapNear.region = MKCoordinateRegionMake(_MyLocationNow, MKCoordinateSpanMake(0.006, 0.006)); + MKMapCamera *MySeeCamera = [MKMapCamera cameraLookingAtCenterCoordinate:_MyLocationNow fromEyeCoordinate:_MyLocationNow eyeAltitude:500 ]; + _MapNear.camera = MySeeCamera; +} + +-(void)MapAddAnnotation:(NSNotification *) Notification{ + NSArray *SharePost = Notification.object; + self.AnnotationPointTarget = [[MKPointAnnotation alloc] init]; + + [_AnnotationPointTarget setTitle: [SharePost objectAtIndex:0]]; + if ([[SharePost objectAtIndex:1] length] >25){ + [_AnnotationPointTarget setSubtitle:[SharePost objectAtIndex:1]]; + } + else{ + [_AnnotationPointTarget setSubtitle:[SharePost objectAtIndex:1]]; + } + UserImagine = [SharePost objectAtIndex:2]; + _AnnotationPointTarget.coordinate = _MyLocationNow; + [_MapNear addAnnotation:_AnnotationPointTarget]; + +} + +- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation{ + if([annotation isKindOfClass:[MKUserLocation class]]) return nil; + if([annotation isKindOfClass:[MKPointAnnotation class]]){ + MKAnnotationView *DefineView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"ShareBy"]; + if(!DefineView){ + DefineView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"ShareBy"]; + [DefineView setImage:PointImagine]; + DefineView.canShowCallout = YES; + + UIView *LeftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; + + UIImage *TargetUserImagine = UserImagine; + UIImageView *TargetImagineView = [[UIImageView alloc] initWithImage:TargetUserImagine]; + [TargetImagineView setFrame:CGRectMake(0, 0, 50, 50)]; + + UIButton *DetailButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + DetailButton.frame = CGRectMake(0, 0, 50, 50); + DetailButton.backgroundColor = [UIColor clearColor]; + [DetailButton setTitle:@"详情" forState:UIControlStateNormal]; + + NSArray *ThisAnnotationDetail = [[NSArray alloc] initWithObjects:annotation,TargetImagineView, nil]; + + + [DetailButton addTarget:self action: @selector(DetailButtonOnClick:) forControlEvents:UIControlEventTouchUpInside]; + + TargetImagineView.contentMode = UIViewContentModeScaleToFill; + [LeftView addSubview:TargetImagineView]; + [DefineView setLeftCalloutAccessoryView:LeftView]; + [DefineView setRightCalloutAccessoryView:DetailButton]; + [DefineView setDetailCalloutAccessoryView:DetailButton]; + DefineView.canShowCallout = YES; + } + return DefineView; + } + return nil; +} + +- (void)DetailButtonOnClick:(UIButton *) button{ + +} + + +-(void)viewDidDisappear:(BOOL)animated{ + [super viewDidDisappear:animated]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +@end diff --git a/MPSE/PointType.ico b/MPSE/PointType.ico new file mode 100644 index 0000000..a1f7cb8 Binary files /dev/null and b/MPSE/PointType.ico differ diff --git a/MPSE/PointType.png b/MPSE/PointType.png new file mode 100644 index 0000000..77690f2 Binary files /dev/null and b/MPSE/PointType.png differ diff --git a/MPSE/Post.h b/MPSE/Post.h new file mode 100644 index 0000000..f87b476 --- /dev/null +++ b/MPSE/Post.h @@ -0,0 +1,17 @@ +// +// Post.h +// MPSE +// +// Created by Saturneric on 17/1/26. +// Copyright © 2017年 Bakantu Eric. All rights reserved. +// + +#import + +@interface MSPost : NSObject + +@property(nonatomic) NSString *UserID; +@property(nonatomic) NSString *PostID; +@property(nonatomic) NSString *Text; + +@end diff --git a/MPSE/User.h b/MPSE/User.h new file mode 100644 index 0000000..c1537d2 --- /dev/null +++ b/MPSE/User.h @@ -0,0 +1,46 @@ +// +// User.h +// MPSE +// +// Created by Saturneric on 17/1/26. +// Copyright © 2017年 Bakantu Eric. All rights reserved. +// + +#import + +@interface MSUserMe : NSObject + +@property(nonatomic) NSString *UserID; +@property(nonatomic) NSString *UserName; +@property(strong, nonatomic) UIImage *UserImage; +@property(strong, nonatomic) UIImage *UserPointType; +@property(strong, nonatomic) NSDictionary *UserInfoDetail; +@property(strong, nonatomic) NSString *UserPasswrodHash; + +@end + +@interface MSLoginMe : NSObject + +@property(nonatomic, weak) MSUserMe *targetUser; + +- (void)doLogin; +- (void)ifLoginSuccess:(MSUserMe *) userInfo; +- (void)ifLoginFailed:(NSString *)error; + +@end + +@interface MSRegisterMe : NSObject + +- (void)doRegister; +- (void)ifRegisterSuccess; + +@end + +@interface MSConnectServer : NSObject + +@property (nonatomic ,weak) NSString *serverIP; +@property (nonatomic ,weak) NSString *serverPort; +@property (nonatomic, weak) NSString *serverCode; + + +@end diff --git a/MPSE/User.m b/MPSE/User.m new file mode 100644 index 0000000..b0a0fc4 --- /dev/null +++ b/MPSE/User.m @@ -0,0 +1,9 @@ +// +// User.m +// MPSE +// +// Created by Saturneric on 17/1/26. +// Copyright © 2017年 Bakantu Eric. All rights reserved. +// + +#import "User.h" diff --git a/MPSE/ViewController.h b/MPSE/ViewController.h index 30072aa..430ef9d 100644 --- a/MPSE/ViewController.h +++ b/MPSE/ViewController.h @@ -7,8 +7,11 @@ // #import +#include -@interface ViewController : UIViewController +#import "Post.h" + +@interface ViewController : UIViewController @end diff --git a/MPSE/ViewController.m b/MPSE/ViewController.m index 54f2cbb..4a39b19 100644 --- a/MPSE/ViewController.m +++ b/MPSE/ViewController.m @@ -10,15 +10,76 @@ @interface ViewController () +@property (weak, nonatomic) IBOutlet UITextView *ShareText; +@property (weak, nonatomic) IBOutlet UIButton *ShareButton; +@property (weak, nonatomic) IBOutlet UILabel *LocationLabel; +@property (strong, nonatomic) CLLocation *ShareLocationNow; + +@property (strong,nonatomic) CLLocationManager *Location; + @end @implementation ViewController +@synthesize ShareButton = _ShareButton; +@synthesize ShareText = _ShareText; +@synthesize Location = _Location; +@synthesize ShareLocationNow = _ShareLocationNow; + - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. + + [[_ShareButton titleLabel] setText:@"分享"]; + _ShareText.text = @"你所在的位置有没有什么新鲜事?"; + _LocationLabel.text = @""; + _ShareText.delegate = self; + + _Location = [[CLLocationManager alloc]init]; + _Location.delegate = self; + _Location.desiredAccuracy = kCLLocationAccuracyBest; + + [_Location requestWhenInUseAuthorization]; + + [_Location startUpdatingLocation]; + + [self.view endEditing:YES]; + } +- (void)textViewDidBeginEditing:(UITextView *)textView{ + _ShareText.text = @""; + +} + +- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ + CLLocation *LocationNow = [locations lastObject]; + CLGeocoder *GeocoderNow = [[CLGeocoder alloc] init]; + [GeocoderNow reverseGeocodeLocation:LocationNow completionHandler:^(NSArray *array, NSError *error){ + if(array.count > 0){ + CLPlacemark *PlacemarkNow = [array objectAtIndex:0]; + NSDictionary *Address = PlacemarkNow.addressDictionary; + NSString *LableDisplay = [[NSString alloc] initWithFormat:@"%@, %@",[Address valueForKey:@"Name"],[Address valueForKey:@"Country"]]; + [_LocationLabel setText: LableDisplay]; + self.ShareLocationNow = LocationNow; + + } + }]; +} + +- (IBAction)ShareClick:(id)sender { + NSString *ShareTextNow = _ShareText.text; + NSString *Username = @"Me"; + UIImage *UserImagine = [UIImage imageNamed:@"Me.png"]; + + NSUUID *PostID = [[NSUUID alloc] init]; + + + NSArray *SharePost = [[NSArray alloc] initWithObjects:Username,ShareTextNow,UserImagine,nil]; + + [[NSNotificationCenter defaultCenter] postNotificationName:@"MapAddTarget" object:SharePost]; + [[[UIApplication sharedApplication] keyWindow] endEditing:YES]; +} - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];