我在做一个Split View-Based Appliaction,需要在代码当中判断当前屏幕方向,并对控件位置作调整,以下代码在单视图项目试过是能起作用的:- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}-(void) positionViews {
UIInterfaceOrientation destOrientation = self.interfaceOrientation;
if (destOrientation == UIInterfaceOrientationPortrait ||
destOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//---if rotating to portrait mode---
NSLog(@"Portrait");
} else {
//---if rotating to landscape mode--
NSLog(@"LandScape");
}
}
-(void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:
(UIInterfaceOrientation) fromInterfaceOrientation
duration: (NSTimeInterval) duration {
NSLog(@"here");
[self positionViews];
}
但是在Split View-Based项目当中,我把以上代码加入DetailViewController.m或者RootViewController.m当中,运行都没有nslog的输出请教各位,在Split View-Based项目当中应该如何判断屏幕旋转方向,谢谢!
return YES;
}-(void) positionViews {
UIInterfaceOrientation destOrientation = self.interfaceOrientation;
if (destOrientation == UIInterfaceOrientationPortrait ||
destOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//---if rotating to portrait mode---
NSLog(@"Portrait");
} else {
//---if rotating to landscape mode--
NSLog(@"LandScape");
}
}
-(void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:
(UIInterfaceOrientation) fromInterfaceOrientation
duration: (NSTimeInterval) duration {
NSLog(@"here");
[self positionViews];
}
但是在Split View-Based项目当中,我把以上代码加入DetailViewController.m或者RootViewController.m当中,运行都没有nslog的输出请教各位,在Split View-Based项目当中应该如何判断屏幕旋转方向,谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货