设备方向导致翻转节点位置

时间:2015-07-23 21:15:58

标签: ios uideviceorientation

我的代码非常简单。我想将SKSpriteNode的位置更改为始终保留在设备屏幕的右下角。我调用了我的UIDeviceOrientationDidChangeNotification方法"旋转"在设备旋转时,它应该只是移动节点,但由于某种原因,它总是翻转所需的位置,因此横向位置是肖像应该在哪里,反之亦然。

我的代码如下:

UI

    - (void)rotated:(NSNotification *)notification {
            DeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
            if (UIDeviceOrientationIsLandscape(deviceOrientation) && !_isShowingLandscapeView)
                [self.node setPosition:bottom_right];
                _isShowingLandscapeView = YES;
            }
            else if (UIDeviceOrientationIsPortrait(deviceOrientation) && _isShowingLandscapeView)
            {
                [self.node setPosition:bottom_right];
                _isShowingLandscapeView = NO;
            }
        }

1 个答案:

答案 0 :(得分:0)

好的,我正在做的很简单。只需在SKScene上使用UIButton即可。回到UIViewController,在那里你可以调用你的skscene并添加按钮。您必须使用NSNotification中心将信息传递给按钮,标签等。

http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=8843