我正在 ios7
中方向工作- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
/**
Changing frame depending on mode
@param interfaceOrientation is UIInterfaceOrientationobject
@param duration is NSTimeInterval object
*/
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
[self landscapeViewFrame];
}
else if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
[self portraitViewFrame];
}
}
其中landscapeViewFrame
包含横向视图(框架)代码,portraitViewFrame
包含纵向视图框架。这些方法用于工作,但在升级到ios7 之后它们不是响应并且没有被调用,我用Google搜索并发现这些方法不再受支持。我已经尝试了其他方法
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;//UIInterfaceOrientationIsPortrait(UIInterfaceOrientationMaskPortrait|| UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
if (self.interfaceOrientation == UIInterfaceOrientationPortrait)
{
}
else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight){
return UIInterfaceOrientationMaskAll;
}
}
但仅调用shouldAutorotate
,而不调用其他willAnimateRotationToInterfaceOrientation
。应该用哪种方法代替这两种方法。 {{1}}应该使用/替换哪种方法。请帮帮我。