File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -246,24 +246,34 @@ - (void)accelerometer:(CMAccelerometerData *)accelerometerData
246
246
_acceleration->timestamp = accelerometerData.timestamp ;
247
247
248
248
double tmp = _acceleration->x ;
249
-
250
- switch ([[[UIApplication sharedApplication ].windows[0 ] windowScene ] interfaceOrientation ])
249
+ UIInterfaceOrientation orientation;
250
+ if (@available (iOS 13.0 , *))
251
+ {
252
+ orientation = [[[UIApplication sharedApplication ].windows[0 ] windowScene ] interfaceOrientation ];
253
+ }
254
+ else
255
+ {
256
+ // Fallback on earlier versions
257
+ orientation = [[UIApplication sharedApplication ] statusBarOrientation ];
258
+ }
259
+
260
+ switch (orientation)
251
261
{
252
262
case UIInterfaceOrientationLandscapeRight:
253
263
_acceleration->x = -_acceleration->y ;
254
264
_acceleration->y = tmp;
255
265
break ;
256
-
266
+
257
267
case UIInterfaceOrientationLandscapeLeft:
258
268
_acceleration->x = _acceleration->y ;
259
269
_acceleration->y = -tmp;
260
270
break ;
261
-
271
+
262
272
case UIInterfaceOrientationPortraitUpsideDown:
263
273
_acceleration->x = -_acceleration->y ;
264
274
_acceleration->y = -tmp;
265
275
break ;
266
-
276
+
267
277
case UIInterfaceOrientationPortrait:
268
278
break ;
269
279
default :
You can’t perform that action at this time.
0 commit comments