teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コードを修正

2021/10/04 07:50

投稿

sugidodan
sugidodan

スコア26

title CHANGED
File without changes
body CHANGED
@@ -93,4 +93,5 @@
93
93
  pitch = (deviceMotion.attitude.pitch)
94
94
  roll = (deviceMotion.attitude.roll)
95
95
  azimuth = (deviceMotion.attitude.yaw)
96
+ }
96
97
  ```

1

コードを追記

2021/10/04 07:50

投稿

sugidodan
sugidodan

スコア26

title CHANGED
File without changes
body CHANGED
@@ -28,7 +28,14 @@
28
28
  }
29
29
  ...
30
30
  中略
31
+ HStack{
32
+ Text(String(format:"%6.2f", builtIn.roll * 180.0/Double.pi)).padding()
33
+ Text(String(format:"%6.2f",builtIn.pitch * 180.0/Double.pi)).padding()
34
+ Text(String(format:"%6.2f",builtIn.azimuth * 180.0/Double.pi)).padding()
35
+ }
31
36
  ...
37
+ 中略
38
+ ...
32
39
  }.navigationBarItems(leading:
33
40
  Button(action: {
34
41
  if builtIn.isStarted {
@@ -77,4 +84,13 @@
77
84
  isStarted = false
78
85
  motionManager.stopDeviceMotionUpdates()
79
86
  }
87
+
88
+ @Published var pitch = 0.0
89
+ @Published var roll = 0.0
90
+ @Published var azimuth = 0.0
91
+
92
+ private func updateMotionData(deviceMotion:CMDeviceMotion) {
93
+ pitch = (deviceMotion.attitude.pitch)
94
+ roll = (deviceMotion.attitude.roll)
95
+ azimuth = (deviceMotion.attitude.yaw)
80
96
  ```