Skip to content

Commit 4f577ca

Browse files
author
UQ Times
committed
Core Motionで、加速度センサー・ジャイロスコープ・電子コンパスを利用するサンプル。
1 parent 477e8cf commit 4f577ca

File tree

5 files changed

+2139
-44
lines changed

5 files changed

+2139
-44
lines changed

CoreMotionSample/CoreMotionSample.xcodeproj/project.pbxproj

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,33 @@
1616
CEBFCA8E1563878A00A67BA5 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CEBFCA8D1563878A00A67BA5 /* ViewController.m */; };
1717
CEBFCA911563878A00A67BA5 /* ViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = CEBFCA8F1563878A00A67BA5 /* ViewController_iPhone.xib */; };
1818
CEBFCA941563878A00A67BA5 /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = CEBFCA921563878A00A67BA5 /* ViewController_iPad.xib */; };
19+
CEBFCA9C15638E5F00A67BA5 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEBFCA9A15638E1F00A67BA5 /* CoreMotion.framework */; };
1920
/* End PBXBuildFile section */
2021

2122
/* Begin PBXFileReference section */
2223
CEBFCA761563878A00A67BA5 /* CoreMotionSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoreMotionSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
2324
CEBFCA7A1563878A00A67BA5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
2425
CEBFCA7C1563878A00A67BA5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
2526
CEBFCA7E1563878A00A67BA5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
26-
CEBFCA821563878A00A67BA5 /* CoreMotionSample-Info.plist */ = {isa = PBXFileReference; path = "CoreMotionSample-Info.plist"; sourceTree = "<group>"; };
27+
CEBFCA821563878A00A67BA5 /* CoreMotionSample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CoreMotionSample-Info.plist"; sourceTree = "<group>"; };
2728
CEBFCA841563878A00A67BA5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2829
CEBFCA861563878A00A67BA5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29-
CEBFCA881563878A00A67BA5 /* CoreMotionSample-Prefix.pch */ = {isa = PBXFileReference; path = "CoreMotionSample-Prefix.pch"; sourceTree = "<group>"; };
30-
CEBFCA891563878A00A67BA5 /* AppDelegate.h */ = {isa = PBXFileReference; path = AppDelegate.h; sourceTree = "<group>"; };
30+
CEBFCA881563878A00A67BA5 /* CoreMotionSample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CoreMotionSample-Prefix.pch"; sourceTree = "<group>"; };
31+
CEBFCA891563878A00A67BA5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
3132
CEBFCA8A1563878A00A67BA5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
32-
CEBFCA8C1563878A00A67BA5 /* ViewController.h */ = {isa = PBXFileReference; path = ViewController.h; sourceTree = "<group>"; };
33+
CEBFCA8C1563878A00A67BA5 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
3334
CEBFCA8D1563878A00A67BA5 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
3435
CEBFCA901563878A00A67BA5 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = "<group>"; };
3536
CEBFCA931563878A00A67BA5 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = "<group>"; };
37+
CEBFCA9A15638E1F00A67BA5 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
3638
/* End PBXFileReference section */
3739

3840
/* Begin PBXFrameworksBuildPhase section */
3941
CEBFCA731563878A00A67BA5 /* Frameworks */ = {
4042
isa = PBXFrameworksBuildPhase;
4143
buildActionMask = 2147483647;
4244
files = (
45+
CEBFCA9C15638E5F00A67BA5 /* CoreMotion.framework in Frameworks */,
4346
CEBFCA7B1563878A00A67BA5 /* UIKit.framework in Frameworks */,
4447
CEBFCA7D1563878A00A67BA5 /* Foundation.framework in Frameworks */,
4548
CEBFCA7F1563878A00A67BA5 /* CoreGraphics.framework in Frameworks */,
@@ -69,6 +72,7 @@
6972
CEBFCA791563878A00A67BA5 /* Frameworks */ = {
7073
isa = PBXGroup;
7174
children = (
75+
CEBFCA9A15638E1F00A67BA5 /* CoreMotion.framework */,
7276
CEBFCA7A1563878A00A67BA5 /* UIKit.framework */,
7377
CEBFCA7C1563878A00A67BA5 /* Foundation.framework */,
7478
CEBFCA7E1563878A00A67BA5 /* CoreGraphics.framework */,
@@ -205,7 +209,10 @@
205209
isa = XCBuildConfiguration;
206210
buildSettings = {
207211
ALWAYS_SEARCH_USER_PATHS = NO;
208-
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
212+
ARCHS = (
213+
armv6,
214+
armv7,
215+
);
209216
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
210217
COPY_PHASE_STRIP = NO;
211218
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -216,11 +223,12 @@
216223
"$(inherited)",
217224
);
218225
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
226+
GCC_THUMB_SUPPORT = NO;
219227
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
220228
GCC_WARN_ABOUT_RETURN_TYPE = YES;
221229
GCC_WARN_UNINITIALIZED_AUTOS = YES;
222230
GCC_WARN_UNUSED_VARIABLE = YES;
223-
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
231+
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
224232
SDKROOT = iphoneos;
225233
TARGETED_DEVICE_FAMILY = "1,2";
226234
};
@@ -230,15 +238,19 @@
230238
isa = XCBuildConfiguration;
231239
buildSettings = {
232240
ALWAYS_SEARCH_USER_PATHS = NO;
233-
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
241+
ARCHS = (
242+
armv6,
243+
armv7,
244+
);
234245
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
235246
COPY_PHASE_STRIP = YES;
236247
GCC_C_LANGUAGE_STANDARD = gnu99;
248+
GCC_THUMB_SUPPORT = NO;
237249
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
238250
GCC_WARN_ABOUT_RETURN_TYPE = YES;
239251
GCC_WARN_UNINITIALIZED_AUTOS = YES;
240252
GCC_WARN_UNUSED_VARIABLE = YES;
241-
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
253+
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
242254
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
243255
SDKROOT = iphoneos;
244256
TARGETED_DEVICE_FAMILY = "1,2";
@@ -251,7 +263,9 @@
251263
buildSettings = {
252264
GCC_PRECOMPILE_PREFIX_HEADER = YES;
253265
GCC_PREFIX_HEADER = "CoreMotionSample/CoreMotionSample-Prefix.pch";
266+
GCC_THUMB_SUPPORT = NO;
254267
INFOPLIST_FILE = "CoreMotionSample/CoreMotionSample-Info.plist";
268+
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
255269
PRODUCT_NAME = "$(TARGET_NAME)";
256270
WRAPPER_EXTENSION = app;
257271
};
@@ -262,7 +276,9 @@
262276
buildSettings = {
263277
GCC_PRECOMPILE_PREFIX_HEADER = YES;
264278
GCC_PREFIX_HEADER = "CoreMotionSample/CoreMotionSample-Prefix.pch";
279+
GCC_THUMB_SUPPORT = NO;
265280
INFOPLIST_FILE = "CoreMotionSample/CoreMotionSample-Info.plist";
281+
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
266282
PRODUCT_NAME = "$(TARGET_NAME)";
267283
WRAPPER_EXTENSION = app;
268284
};
@@ -287,6 +303,7 @@
287303
CEBFCA991563878A00A67BA5 /* Release */,
288304
);
289305
defaultConfigurationIsVisible = 0;
306+
defaultConfigurationName = Release;
290307
};
291308
/* End XCConfigurationList section */
292309
};

CoreMotionSample/CoreMotionSample/CoreMotionSample-Info.plist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,10 @@
3131
<key>UISupportedInterfaceOrientations</key>
3232
<array>
3333
<string>UIInterfaceOrientationPortrait</string>
34-
<string>UIInterfaceOrientationLandscapeLeft</string>
35-
<string>UIInterfaceOrientationLandscapeRight</string>
3634
</array>
3735
<key>UISupportedInterfaceOrientations~ipad</key>
3836
<array>
3937
<string>UIInterfaceOrientationPortrait</string>
40-
<string>UIInterfaceOrientationPortraitUpsideDown</string>
41-
<string>UIInterfaceOrientationLandscapeLeft</string>
42-
<string>UIInterfaceOrientationLandscapeRight</string>
4338
</array>
4439
</dict>
4540
</plist>

CoreMotionSample/CoreMotionSample/ViewController.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,28 @@
1010

1111
@interface ViewController : UIViewController
1212

13+
@property (nonatomic, retain) IBOutlet UILabel *accelerometerDataXLabel;
14+
@property (nonatomic, retain) IBOutlet UILabel *accelerometerDataYLabel;
15+
@property (nonatomic, retain) IBOutlet UILabel *accelerometerDataZLabel;
16+
@property (nonatomic, retain) IBOutlet UILabel *gyroDataXLabel;
17+
@property (nonatomic, retain) IBOutlet UILabel *gyroDataYLabel;
18+
@property (nonatomic, retain) IBOutlet UILabel *gyroDataZLabel;
19+
@property (nonatomic, retain) IBOutlet UILabel *magnetometerDataXLabel;
20+
@property (nonatomic, retain) IBOutlet UILabel *magnetometerDataYLabel;
21+
@property (nonatomic, retain) IBOutlet UILabel *magnetometerDataZLabel;
22+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionAccelerometerXLabel;
23+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionAccelerometerYLabel;
24+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionAccelerometerZLabel;
25+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionGyroXLabel;
26+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionGyroYLabel;
27+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionGyroZLabel;
28+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionMagnetometerXLabel;
29+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionMagnetometerYLabel;
30+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionMagnetometerZLabel;
31+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionMagnetometerCalibrationAccuracyLabel;
32+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionMagnetometerAzimuthLabel;
33+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionAttitudeRoll;
34+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionAttitudePitch;
35+
@property (nonatomic, retain) IBOutlet UILabel *deviceMotionAttitudeYaw;
36+
1337
@end

0 commit comments

Comments
 (0)