{"id":578,"date":"2018-02-23T23:40:10","date_gmt":"2018-02-23T15:40:10","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/ios%e5%8a%a0%e9%80%9f%e5%ba%a6%e4%bc%a0%e6%84%9f%e5%99%a8accelerometer\/"},"modified":"2018-02-23T23:40:10","modified_gmt":"2018-02-23T15:40:10","slug":"ios%e5%8a%a0%e9%80%9f%e5%ba%a6%e4%bc%a0%e6%84%9f%e5%99%a8accelerometer","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=578","title":{"rendered":"iOS\u52a0\u901f\u5ea6\u4f20\u611f\u5668(accelerometer)"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>IOS\u52a0\u901f\u5ea6\u4f20\u611f\u5668(accelerometer)<\/h1>\n<hr>\n<h2>\u7b80\u4ecb<\/h2>\n<p>\u52a0\u901f\u5ea6\u4f20\u611f\u5668\u662f\u6839\u636ex\u3001y\u548cz\u4e09\u4e2a\u65b9\u5411\u6765\u68c0\u6d4b\u5728\u8bbe\u5907\u4f4d\u7f6e\u7684\u6539\u53d8\u3002<\/p>\n<p>\u901a\u8fc7\u52a0\u901f\u5ea6\u4f20\u611f\u5668\u53ef\u4ee5\u77e5\u9053\u5f53\u524d\u8bbe\u5907\u76f8\u5bf9\u4e8e\u5730\u9762\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u4ee5\u4e0b\u5b9e\u4f8b\u4ee3\u7801\u9700\u8981\u5728\u771f\u5b9e\u8bbe\u5907\u4e0a\u8fd0\u884c\uff0c\u5728\u6a21\u62df\u5668\u4e0a\u662f\u65e0\u6cd5\u5de5\u4f5c\u7684\u3002<\/p>\n<h3>\u5b9e\u4f8b\u6b65\u9aa4<\/h3>\n<p>1\u3001\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u89c6\u56fe\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>2\u3001\u5728ViewController.xib\u4e2d\u6dfb\u52a0\u4e09\u4e2a\u6807\u7b7e\uff0c\u5e76\u521b\u5efa\u4e00\u4e2aibOutlets\u5206\u522b\u4e3a\uff1axlable\u3001ylabel\u548czlabel<\/p>\n<p>3\u3001\u5982\u4e0b\u6240\u793a\uff0c\u66f4\u65b0ViewController.h<\/p>\n<pre>\n#import &lt;UIKit\/UIKit.h&gt;\n\n@interface ViewController : UIViewController&lt;UIAccelerometerDelegate&gt;\n{\n    IBOutlet UILabel *xlabel;\n    IBOutlet UILabel *ylabel;\n    IBOutlet UILabel *zlabel;\n\n}\n@end\n<\/pre>\n<p>4\u3001\u5982\u4e0b\u6240\u793a\uff0c\u66f4\u65b0ViewController.m<\/p>\n<pre>\n#import \"ViewController.h\"\n\n@interface ViewController ()\n\n@end\n\n@implementation ViewController\n\n- (void)viewDidLoad\n{\n    [super viewDidLoad];\n    [[UIAccelerometer sharedAccelerometer]setDelegate:self];\n    \/\/Do any additional setup after loading the view,typically from a nib\n}\n\n- (void)didReceiveMemoryWarning\n{\n    [super didReceiveMemoryWarning];\n    \/\/ Dispose of any resources that can be recreated.\n}\n- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:\n  (UIAcceleration *)acceleration{\n    [xlabel setText:[NSString stringWithFormat:@\"%f\",acceleration.x]];\n    [ylabel setText:[NSString stringWithFormat:@\"%f\",acceleration.y]];\n    [zlabel setText:[NSString stringWithFormat:@\"%f\",acceleration.z]];\n}\n\n@end\n<\/pre>\n<h3>\u8f93\u51fa<\/h3>\n<p>\u5f53\u6211\u4eec\u5728iPhone\u8bbe\u5907\u4e2d\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f\uff0c\u5f97\u5230\u7684\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-full\" alt=\"accelerometer_Output\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2013\/11\/accelerometer_Output.jpg\" width=\"250\" height=\"375\" data-pinit=\"registered\"><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">IOS\u52a0\u901f\u5ea6\u4f20\u611f\u5668(accelerometer) \u7b80\u4ecb \u52a0\u901f\u5ea6\u4f20\u611f\u5668\u662f\u6839\u636ex\u3001y\u548cz\u4e09\u4e2a\u65b9&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=578\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,26],"tags":[74,93],"class_list":["post-578","post","type-post","status-publish","format-standard","hentry","category-ios","category-mobile","tag-ios","tag-mobile","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=578"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/578\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}