我正在将我的应用程序转换为ios6,但我遇到了旋转问题。有人能告诉我旋转设备时需要调用哪些方法吗?
发布于 2012-11-20 13:24:46
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self doLayoutForOrientation:toInterfaceOrientation];
}
- (void)doLayoutForOrientation:(UIInterfaceOrientation)orientation {
if (UIInterfaceOrientationIsPortrait(orientation))
{
//set the frames here
}
else
{
//set the frames here
}
}这些是ios 6中的新方法,您可以根据方向设置帧。希望能对你有所帮助。
发布于 2012-11-19 14:07:37
- (BOOL) shouldAutorotate -(NSUInteger)supportedInterfaceOrientations
这些是添加到iOS 6中的新功能。
发布于 2012-11-19 14:48:59
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
-(void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
{
//set the frames here
}
else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
{
//set the frames here
}
}最好这样做,当你每次改变设备的方向时,上面的方法都会被调用。
https://stackoverflow.com/questions/13448192
复制相似问题