0
我正在創建一個UIScrollView子類,當設備方向更改時需要運行動畫。爲了做到這一點,我需要知道方向改變的確切時間。在視圖控制器我剛使用這樣的:檢測子類的方向改變的持續時間? iOS7
-(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");
}
唯一的問題是它不告訴我設備方向的持續時間。有誰知道如何得到它?