{"id":344,"date":"2014-12-04T15:55:18","date_gmt":"2014-12-04T07:55:18","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=344"},"modified":"2016-07-15T17:33:58","modified_gmt":"2016-07-15T09:33:58","slug":"v2-5-0%e9%80%82%e9%85%8dios8%ef%bc%8c%e8%a7%a3%e5%86%b3%e5%ae%9a%e4%bd%8d%e9%97%ae%e9%a2%98%ef%bc%88%e4%ba%b2%e6%b5%8b%e5%8f%af%e7%94%a8%ef%bc%81%ef%bc%81%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2014\/12\/04\/155518344.html","title":{"rendered":"v2.5.0\u9002\u914dios8\uff0c\u89e3\u51b3\u5b9a\u4f4d\u95ee\u9898\uff08\u4eb2\u6d4b\u53ef\u7528\uff01\uff01\uff09"},"content":{"rendered":"<p>\u767e\u5ea6\u5f00\u53d1\u8005\u8bba\u575b\u4e2d\u6709\u5f88\u591a\u7f51\u53cb\u5410\u69fd\uff0c\u767e\u5ea6SDK\u5bf9ios8\u7684\u652f\u6301\u4e0d\u662f\u5f88\u597d\uff0c\u73b0\u5bf9\u8fd9\u4e9b\u95ee\u9898\u4e00\u4e00\u8fdb\u884c\u603b\u7ed3\uff1a<\/p>\n<p>1\u3001\u5728info.plist\u6587\u4ef6\u4e2d\u65b0\u589e\u52a0\u4e24\u4e2a\u952e\u503c\u5bf9\uff0cKey\u5206\u522b\u4e3a\uff1a<br \/>\n<span style=\"font-family: Arial;\">NSLocationWhenInUseUsageDescription<br \/>\nNSLocationAlwaysUsageDescription<\/span><br \/>\n\u8fd9\u4e24\u4e2aKey\u5bf9\u5e94\u7684Value\u90fd\u4e3a\u5b57\u7b26\u4e32\uff0c\u524d\u8005\u7528\u6765\u589e\u52a0\u7528\u6237\u4f7f\u7528GPS\u65f6\u9644\u52a0\u5728\u63d0\u793a\u6846\u4e0a\u7684\u53cb\u597d\u63d0\u793a\u201c\u7c7b\u4f3c\u5141\u8bb8xxx\u4f7f\u7528\u5f53\u524d\u5b9a\u4f4d\u4fe1\u606f\u7b49\u7b49\u201d\uff0c\u540e\u8005\u610f\u4e3a\u5728\u540e\u53f0\u4f7f\u7528GPS\u65f6\u7528\u6237\u63d0\u793a\u4fe1\u606f\uff08<span style=\"color: #ff00ff;\">iOS8\u624d\u6709<\/span>\uff09\uff0c\u8fd9\u4e2a\u767e\u5ea6\u5b98\u65b9\u5728SDK\u4f7f\u7528\u65f6\u6709\u7279\u522b\u8bf4\u660e\u3002<\/p>\n<p>2\u3001\u5b9a\u4f4d\u65f6\u4f1a\u51fa\u73b0\u6ca1\u6709\u8fd4\u56de\u4f4d\u7f6e\u4fe1\u606f\u7684\u4fe1\u606f\uff0c\u8c03\u7528<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">startUserLocationService<\/span><\/span>\u65f6\u4ee3\u7406\u65b9\u6cd5<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">didUpdateUserLocation:<\/span><\/span>\u6ca1\u6709\u8fd4\u56de\u4f4d\u7f6e\u4fe1\u606f\uff0c\u800c\u5728<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">didFailToLocateUserWithError:<\/span><\/span>\u4e2d\u8fd4\u56de\u4e86\u9519\u8bef\u4fe1\u606f\uff0cError Domain=kCLErrorDomain Code=0 &#8220;The operation couldn\u2019t be completed. (kCLErrorDomain error 0.)&#8221;\uff0c<\/p>\n<p>2.1\u3001\u8fd9\u4e2a\u95ee\u9898\u6709\u7f51\u53cb\u8bf4\u5728xCode6\u4e0a\u7f16\u8bd1\u5c31\u4f1a\u51fa\u73b0\uff0c\u4e5f\u6709\u8bf4\u5728iPhone6\u4e0a\u4f1a\u51fa\u73b0\uff0c\u5176\u5b9e\u5e76\u4e0d\u5b8c\u5168\u5bf9\uff0c\u6700\u9760\u8c31\u7684\u8bf4\u6cd5\u662f\u5728ios8\u53ca\u4ee5\u4e0a\u7248\u672c\u90fd\u4f1a\u51fa\u73b0\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u95ee\u9898\u672c\u8d28\u4e0eiOS\u7248\u672c\u76f8\u5173\uff0c\u4e0e\u786c\u4ef6\u53ca\u5f00\u53d1\u73af\u5883\u65e0\u76f4\u63a5\u5173\u8054\uff08\u4e00\u4e2a\u672c\u4eba\u672a\u53bb\u8bc1\u5b9e\u7684\u6d88\u606f\uff0c\u9ad8\u5fb7\u5730\u56fe\u4e5f\u5b58\u5728\u7c7b\u4f3c\u60c5\u51b5\uff09\uff0c\u5176\u6839\u672c\u539f\u56e0\u767e\u5ea6\u5730\u56fe\u8bba\u575b\u91cc\u6709\u7f51\u53cb\u5df2\u7ecf\u89e3\u91ca\u4e86\uff0c\u4e0eios8\u7684\u6388\u6743\u6709\u5173\uff0c\u77e5\u9053\u8fd9\u70b9\u5c31\u53ef\u4ee5\u4e86\u4e0d\u7528\u7ec6\u8bb2\u3002<\/p>\n<p>2.2\u3001\u89e3\u51b3\u65b9\u6848\uff1a\u5728\u5f00\u542f\u767e\u5ea6\u5730\u56fe\u4e4b\u524d\u5148\u8c03\u7528\u4e0b\u9762\u4ee3\u7801\uff08\u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u5426\u5219\u63d0\u793a\u4f1a\u95ea\u9000\uff09<\/p>\n<p>@property (nonatomic, strong) CLLocationManager *locationMgr;<\/p>\n<pre lang=\"objc\" line=\"1\">    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) {\n        \/\/\u7531\u4e8eIOS8\u4e2d\u5b9a\u4f4d\u7684\u6388\u6743\u673a\u5236\u6539\u53d8 \u9700\u8981\u8fdb\u884c\u624b\u52a8\u6388\u6743\n        self.locationMgr = [[CLLocationManager alloc] init];\n        \/\/\u83b7\u53d6\u6388\u6743\u8ba4\u8bc1\n        [self.locationMgr requestAlwaysAuthorization];\n        [self.locationMgr requestWhenInUseAuthorization];\n    }<\/pre>\n<p>2.3\u3001\u5230\u4e0a\u9762\u4e3a\u6b62\uff0c\u76f8\u4fe1\u5f88\u591a\u6ce1\u8bba\u575b\u7684\u7f51\u53cb\u5df2\u7ecf\u65e9\u770b\u8fc7\u7c7b\u4f3c\u7684\u8d34\u5b50\u4e86\uff0c\u4e0d\u597d\u4f7f\uff0c\u8be5\u62a5\u9519\u7684\u4f9d\u65e7\u62a5\u9519\uff0c\u5176\u5b9e\u95ee\u9898\u5df2\u7ecf\u89e3\u51b3\u4e8680%\uff0c\u8fd8\u5dee\u4e00\u70b9\u70b9\uff0c\u53ef\u80fd\u7684\u539f\u56e0\u5982\u4e0b\uff1a<br \/>\nA\u3001\u9000\u51fa\u6a21\u62df\u5668\uff0c\u91cd\u65b0\u7f16\u8bd1\u8fd0\u884c\uff08\u6709\u6548\uff01\uff09<br \/>\nB\u3001Clean\u5de5\u7a0b\uff0c\u5220\u9664App\uff0c\u91cd\u65b0\u7f16\u8bd1\u8fd0\u884c\uff08\u6548\u679c\u4e0d\u660e\u663e\uff09<br \/>\nC\u3001\u8fd8\u539f\u6a21\u62df\u5668\u6240\u6709\u8bbe\u7f6e\uff0c\u6062\u590d\u521d\u59cb\u503c\uff08\u6709\u6548\uff01\uff09<br \/>\nD\u3001\u5220\u9664xCode\u7f13\u5b58\u76ee\u5f55\u53ca\u6587\u4ef6<br \/>\n<span style=\"color: #ff0000;\">E\u3001Clean\u5de5\u7a0b\uff0c\u8fd8\u539f\u6a21\u62df\u5668\uff0c\u5220\u9664\u7f13\u5b58\u6587\u4ef6\u76ee\u5f55\uff0c\u9000\u51fa\u6a21\u62df\u5668\uff0c\u518d\u91cd\u65b0\u7f16\u8bd1\u8fd0\u884c\uff08\u53ef\u884c\u602799%\uff0c\u5f3a\u529b\u63a8\u8350\uff01\uff01\uff09<\/span><br \/>\nF\u3001\u5982\u679c\u662f\u771f\u673a\uff0c<strong>\u8bbe\u7f6e&#8211;\u901a\u7528&#8211;\u8fd8\u539f&#8211;\u8fd8\u539f\u4f4d\u7f6e\u4e0e\u9690\u79c1<\/strong><\/p>\n<p>2.4\u3001\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u6ca1\u6709<span style=\"color: #ff00ff;\">\u8fd8\u539f\u6a21\u62df\u5668<\/span>\u6216<span style=\"color: #ff00ff;\">\u771f\u673a\u8fd8\u539f\u4f4d\u7f6e\u9690\u79c1<\/span>\uff0c\u4f4d\u7f6e\u5750\u6807\u4fe1\u606f\u65e0\u6cd5\u8fd4\u56de\uff0c<span style=\"color: #ff0000;\">\u4f46\u65b0\u5b89\u88c5\u7684\u673a\u5668\u662fOK\u7684\uff0c\u6240\u4ee5\u4e00\u5b9a\u8981\u8fd8\u539f\uff01\uff01<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u767e\u5ea6\u5f00\u53d1\u8005\u8bba\u575b\u4e2d\u6709\u5f88\u591a\u7f51\u53cb\u5410\u69fd\uff0c\u767e\u5ea6SDK\u5bf9ios8\u7684\u652f\u6301\u4e0d\u662f\u5f88\u597d\uff0c\u73b0\u5bf9\u8fd9\u4e9b\u95ee\u9898\u4e00\u4e00\u8fdb\u884c\u603b\u7ed3\uff1a 1\u3001\u5728info.plist\u6587\u4ef6\u4e2d\u65b0\u589e\u52a0\u4e24\u4e2a\u952e\u503c\u5bf9\uff0cKey\u5206\u522b\u4e3a\uff1a NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription \u8fd9\u4e24\u4e2aKey\u5bf9\u5e94\u7684Value\u90fd\u4e3a\u5b57\u7b26\u4e32\uff0c\u524d\u8005\u7528\u6765\u589e\u52a0\u7528\u6237\u4f7f\u7528GPS\u65f6\u9644\u52a0\u5728\u63d0\u793a\u6846\u4e0a\u7684\u53cb\u597d\u63d0\u793a\u201c\u7c7b\u4f3c\u5141\u8bb8xxx\u4f7f\u7528\u5f53\u524d\u5b9a\u4f4d\u4fe1\u606f\u7b49\u7b49\u201d\uff0c\u540e\u8005\u610f\u4e3a\u5728\u540e\u53f0\u4f7f\u7528GPS\u65f6\u7528\u6237\u63d0\u793a\u4fe1\u606f\uff08iOS8\u624d\u6709\uff09\uff0c\u8fd9\u4e2a\u767e\u5ea6\u5b98\u65b9\u5728SDK\u4f7f\u7528\u65f6\u6709\u7279\u522b\u8bf4\u660e\u3002 2\u3001\u5b9a\u4f4d\u65f6\u4f1a\u51fa\u73b0\u6ca1\u6709\u8fd4\u56de\u4f4d\u7f6e\u4fe1\u606f\u7684\u4fe1\u606f\uff0c\u8c03\u7528startUserLocationService\u65f6\u4ee3\u7406\u65b9\u6cd5didUpdateUserLocation:\u6ca1\u6709\u8fd4\u56de\u4f4d\u7f6e\u4fe1\u606f\uff0c\u800c\u5728didFailToLocateUserWithError:\u4e2d\u8fd4\u56de\u4e86\u9519\u8bef\u4fe1\u606f\uff0cError Domain=kCLErrorDomain Code=0 &#8220;The operation couldn\u2019t be completed. (kCLErrorDomain error 0.)&#8221;\uff0c 2.1\u3001\u8fd9\u4e2a\u95ee\u9898\u6709\u7f51\u53cb\u8bf4\u5728xCode6\u4e0a\u7f16\u8bd1\u5c31\u4f1a\u51fa\u73b0\uff0c\u4e5f\u6709\u8bf4\u5728iPhone6\u4e0a\u4f1a\u51fa\u73b0\uff0c\u5176\u5b9e\u5e76\u4e0d\u5b8c\u5168\u5bf9\uff0c\u6700\u9760\u8c31\u7684\u8bf4\u6cd5\u662f\u5728ios8\u53ca\u4ee5\u4e0a\u7248\u672c\u90fd\u4f1a\u51fa\u73b0\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u95ee\u9898\u672c\u8d28\u4e0eiOS\u7248\u672c\u76f8\u5173\uff0c\u4e0e\u786c\u4ef6\u53ca\u5f00\u53d1\u73af\u5883\u65e0\u76f4\u63a5\u5173\u8054\uff08\u4e00\u4e2a\u672c\u4eba\u672a\u53bb\u8bc1\u5b9e\u7684\u6d88\u606f\uff0c\u9ad8\u5fb7\u5730\u56fe\u4e5f\u5b58\u5728\u7c7b\u4f3c\u60c5\u51b5\uff09\uff0c\u5176\u6839\u672c\u539f\u56e0\u767e\u5ea6\u5730\u56fe\u8bba\u575b\u91cc\u6709\u7f51\u53cb\u5df2\u7ecf\u89e3\u91ca\u4e86\uff0c\u4e0eios8\u7684\u6388\u6743\u6709\u5173\uff0c\u77e5\u9053\u8fd9\u70b9\u5c31\u53ef\u4ee5\u4e86\u4e0d\u7528\u7ec6\u8bb2\u3002 2.2\u3001\u89e3\u51b3\u65b9\u6848\uff1a\u5728\u5f00\u542f\u767e\u5ea6\u5730\u56fe\u4e4b\u524d\u5148\u8c03\u7528\u4e0b\u9762\u4ee3\u7801\uff08\u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u5426\u5219\u63d0\u793a\u4f1a\u95ea\u9000\uff09 @property (nonatomic, strong) CLLocationManager *locationMgr; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) { \/\/\u7531\u4e8eIOS8\u4e2d\u5b9a\u4f4d\u7684\u6388\u6743\u673a\u5236\u6539\u53d8 \u9700\u8981\u8fdb\u884c\u624b\u52a8\u6388\u6743 self.locationMgr = [[CLLocationManager alloc] init]; \/\/\u83b7\u53d6\u6388\u6743\u8ba4\u8bc1 [self.locationMgr requestAlwaysAuthorization]; [self.locationMgr requestWhenInUseAuthorization]; } 2.3\u3001\u5230\u4e0a\u9762\u4e3a\u6b62\uff0c\u76f8\u4fe1\u5f88\u591a\u6ce1\u8bba\u575b\u7684\u7f51\u53cb\u5df2\u7ecf\u65e9\u770b\u8fc7\u7c7b\u4f3c\u7684\u8d34\u5b50\u4e86\uff0c\u4e0d\u597d\u4f7f\uff0c\u8be5\u62a5\u9519\u7684\u4f9d\u65e7\u62a5\u9519\uff0c\u5176\u5b9e\u95ee\u9898\u5df2\u7ecf\u89e3\u51b3\u4e8680%\uff0c\u8fd8\u5dee\u4e00\u70b9\u70b9\uff0c\u53ef\u80fd\u7684\u539f\u56e0\u5982\u4e0b\uff1a A\u3001\u9000\u51fa\u6a21\u62df\u5668\uff0c\u91cd\u65b0\u7f16\u8bd1\u8fd0\u884c\uff08\u6709\u6548\uff01\uff09 B\u3001Clean\u5de5\u7a0b\uff0c\u5220\u9664App\uff0c\u91cd\u65b0\u7f16\u8bd1\u8fd0\u884c\uff08\u6548\u679c\u4e0d\u660e\u663e\uff09 C\u3001\u8fd8\u539f\u6a21\u62df\u5668\u6240\u6709\u8bbe\u7f6e\uff0c\u6062\u590d\u521d\u59cb\u503c\uff08\u6709\u6548\uff01\uff09 D\u3001\u5220\u9664xCode\u7f13\u5b58\u76ee\u5f55\u53ca\u6587\u4ef6 E\u3001Clean\u5de5\u7a0b\uff0c\u8fd8\u539f\u6a21\u62df\u5668\uff0c\u5220\u9664\u7f13\u5b58\u6587\u4ef6\u76ee\u5f55\uff0c\u9000\u51fa\u6a21\u62df\u5668\uff0c\u518d\u91cd\u65b0\u7f16\u8bd1\u8fd0\u884c\uff08\u53ef\u884c\u602799%\uff0c\u5f3a\u529b\u63a8\u8350\uff01\uff01\uff09 F\u3001\u5982\u679c\u662f\u771f\u673a\uff0c\u8bbe\u7f6e&#8211;\u901a\u7528&#8211;\u8fd8\u539f&#8211;\u8fd8\u539f\u4f4d\u7f6e\u4e0e\u9690\u79c1 2.4\u3001\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u6ca1\u6709\u8fd8\u539f\u6a21\u62df\u5668\u6216\u771f\u673a\u8fd8\u539f\u4f4d\u7f6e\u9690\u79c1\uff0c\u4f4d\u7f6e\u5750\u6807\u4fe1\u606f\u65e0\u6cd5\u8fd4\u56de\uff0c\u4f46\u65b0\u5b89\u88c5\u7684\u673a\u5668\u662fOK\u7684\uff0c\u6240\u4ee5\u4e00\u5b9a\u8981\u8fd8\u539f\uff01\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[13],"class_list":["post-344","post","type-post","status-publish","format-standard","hentry","category-project","tag-bdmap"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=344"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/344\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}