Objective c UID设备';s BegingeratingDeviceOrientationNotifications不';工作不好

Objective c UID设备';s BegingeratingDeviceOrientationNotifications不';工作不好,objective-c,cocoa-touch,orientation,Objective C,Cocoa Touch,Orientation,我在UIView的子类中有一个子视图。旋转设备时,我希望删除子视图。这是我的代码: - (void)awakeFromNib { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UID

我在UIView的子类中有一个子视图。旋转设备时,我希望删除子视图。这是我的代码:

- (void)awakeFromNib
{
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification object:nil];

}

- (void)orientationChanged
{
    [subview removeFromSuperview];
}

我的问题是,即使设备稍微倾斜,或者放在例如子视图移除的表上。我能做些什么来防止这种情况发生?

不要跟踪设备方向。跟踪接口方向。使用而不是
UIDeviceOrientationIDChangeNotification
,并从通知的
userInfo
中获取新的接口方向。(如果您跟踪界面方向,则无需执行
BegingeratingDeviceOrientationNotifications

您的应用程序是否支持多种界面方向?是否有办法强制调用此功能?我有一个版本的纵向视图,我需要在纵向视图中显示,但默认设置为横向视图。。。