Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 检测子类方向更改的持续时间?损失7_Ios_Ios7_Uiinterfaceorientation_Nsnotificationcenter - Fatal编程技术网

Ios 检测子类方向更改的持续时间?损失7

Ios 检测子类方向更改的持续时间?损失7,ios,ios7,uiinterfaceorientation,nsnotificationcenter,Ios,Ios7,Uiinterfaceorientation,Nsnotificationcenter,我正在创建一个UIScrollView子类,它需要在设备方向发生变化时运行动画。为了做到这一点,我需要知道方向改变的确切持续时间。在视图控制器中,我会使用以下内容: -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { NSLog(@"%f", duration); } 因为这是一个子类,所以我需

我正在创建一个UIScrollView子类,它需要在设备方向发生变化时运行动画。为了做到这一点,我需要知道方向改变的确切持续时间。在视图控制器中,我会使用以下内容:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    NSLog(@"%f", duration);
}
因为这是一个子类,所以我需要使用以下代码:

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
然后调用选择器:

-(void)orientationChanged:(id)selector
{
    NSLog(@"Orientation has changed");
}

唯一的问题是它没有告诉我设备定向的持续时间。有人知道如何获取它吗?

您要查找的属性是UIApplication的
statusBarOrientationAnimationDuration
。这是一个90度的旋转,如果你在处理180度的旋转,它会加倍