{"id":3887,"date":"2016-05-09T16:26:10","date_gmt":"2016-05-09T08:26:10","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=3887"},"modified":"2016-05-09T16:29:59","modified_gmt":"2016-05-09T08:29:59","slug":"ios%e5%bc%80%e5%8f%91%e4%b8%ba%e7%a8%8b%e5%ba%8f%e8%af%b7%e6%b1%82%e5%a7%8b%e7%bb%88%e8%ae%bf%e9%97%ae%e4%bd%8d%e7%bd%ae%e7%9a%84%e6%9d%83%e9%99%90","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=3887","title":{"rendered":"[iOS\u5f00\u53d1]\u4e3a\u7a0b\u5e8f\u8bf7\u6c42\u59cb\u7ec8\u8bbf\u95ee\u4f4d\u7f6e\u7684\u6743\u9650"},"content":{"rendered":"<p>\u4f7f\u7528 Delphi \u5f00\u53d1\u5b9a\u4f4d\u76f8\u5173\u7684\u5e94\u7528\u65f6\uff0cTLocationSensor \u8bf7\u6c42\u7684\u5b9a\u4f4d\u6743\u9650\u662f\u201c\u4f7f\u7528\u5e94\u7528\u671f\u95f4\u201d\uff0c\u8fd9\u6837\u5b50\uff0c\u7a0b\u5e8f\u4e00\u65e6\u5207\u5165\u540e\u53f0\uff0c\u4f60\u7684\u5e94\u7528\u5c31\u5c06\u88ab\u51bb\u7ed3\u8fdb\u5165\u51ac\u7720\u72b6\u6001\uff0c\u7ed3\u679c\u5c31\u4f1a\u9020\u6210\u5207\u6362\u5230\u540e\u53f0\u540e\u65e0\u6cd5\u83b7\u53d6\u4f4d\u7f6e\u4fe1\u606f\uff0c\u76f4\u5230\u4f60\u7684\u7a0b\u5e8f\u88ab\u5524\u9192\u3002<\/p>\n<p>\u5982\u679c\u4f60\u7684\u5e94\u7528\u8981\u6c42\u5728\u540e\u53f0\u65f6\u4e5f\u80fd\u8bbf\u95ee\u4f4d\u7f6e\u4fe1\u606f\uff0c\u5219\u4f60\u9700\u8981\u624b\u52a8\u7533\u8bf7\u4f4d\u7f6e\u8bbf\u95ee\u6743\u9650\u4e3a\u59cb\u7ec8\u3002\u8981\u5b8c\u6210\u8fd9\u4e00\u6b65\uff0c\u4f60\u9700\u8981\uff1a<\/p>\n<p>1\u3001\u5f15\u7528 iOSapi.CoreLocation \u5355\u5143\uff1b<\/p>\n<p>2\u3001\u5982\u679c\u7a97\u4f53\u4e0a\u6709 TLocationSensor \u7ec4\u4ef6\uff0c\u8bf7\u786e\u4fdd\u5b83\u7684 Active \u88ab\u8bbe\u7f6e\u4e3a\u4e86 false\u3002<\/p>\n<p>3\u3001\u5728\u7a97\u4f53\u7684 OnCreate \u4e8b\u4ef6\u4e2d\uff0c\u624b\u52a8\u521b\u5efa CLLocationManager \u5b9e\u4f8b\uff0c\u5e76\u8bf7\u6c42\u4f4d\u7f6e\u8bbf\u95ee\u6743\u9650\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">procedure TForm1.FormCreate(Sender: TObject);\r\nvar\r\n  AMgr: CLLocationManager;\r\nbegin\r\n  FStartTime := Now;\r\n  AMgr := TCLLocationManager.Create;\r\n  AMgr.requestAlwaysAuthorization;\r\nend;<\/pre>\n<p>4\u3001\u5b8c\u6210\u540e\uff0c\u8bbe\u7f6eTLocationSensor\u7684 Active \u4e3a true\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u73b0\u5728\u6743\u9650\u7533\u8bf7\u5b8c\u4e86\uff0c\u4e3a\u4e86\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u80fd\u591f\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u8fdb\u5165\u5de5\u7a0b\u9009\u9879\u4e2d\u8bbe\u7f6e\u4e00\u4e0b\uff1a<\/p>\n<p><a href=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2016\/05\/locationbackground.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3888\" src=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2016\/05\/locationbackground.png\" alt=\"locationbackground\" width=\"721\" height=\"515\" srcset=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2016\/05\/locationbackground.png 721w, https:\/\/blog.qdac.cc\/wp-content\/uploads\/2016\/05\/locationbackground-300x214.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/a><\/p>\n<p>\u5426\u5219\u4f60\u7684\u7a0b\u5e8f\u5728\u5207\u51fa\u524d\u53f0\u6216\u9501\u5c4f\u540e\u4e0d\u4f1a\u5f97\u5230\u4efb\u4f55\u54cd\u5e94\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u6ce8\u610f\u4e0b\u00a0NSLocationAlwaysUsageDescription \u548c\u00a0NSLocationWhenInUseUsageDescription \u8fd9\u4e24\u4e2a\u5b57\u7b26\u4e32\u6700\u597d\u8bbe\u7f6e\u4e00\u4e0b\uff0c\u5b83\u4f1a\u663e\u793a\u5728\u4f60\u7533\u8bf7\u6743\u9650\u65f6\uff0ciOS \u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\u3002\u4f60\u53ef\u4ee5\u5199\u4e00\u4e9b\u4e3a\u5565\u4f60\u8981\u7533\u8bf7\u8fd9\u4e2a\u6743\u9650\uff0c\u8ba9\u7528\u6237\u80fd\u591f\u786e\u5b9a\u662f\u5426\u8981\u7ed9\u4f60\u6388\u6743\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 Delphi \u5f00\u53d1\u5b9a\u4f4d\u76f8\u5173\u7684\u5e94\u7528\u65f6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8,602,603],"tags":[318,620],"class_list":["post-3887","post","type-post","status-publish","format-standard","hentry","category-delphi","category-ios","category-603","tag-318","tag-620"],"views":7685,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3887"}],"version-history":[{"count":3,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3887\/revisions"}],"predecessor-version":[{"id":3890,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3887\/revisions\/3890"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}