gpt4 book ai didi

objective-c - 旋转 Ipad 时动画 View 转换

转载 作者:行者123 更新时间:2023-11-28 19:24:21 27 4
gpt4 key购买 nike

您好,提前感谢您的任何回复。

我的 iPad 应用有两种不同的 View :一种是纵向 View ,一种是横向 View 。当我旋转设备时, View 之间的过渡不是很平滑。我想为两个 View 之间的过渡设置动画,使其看起来更好。这是我的轮换代码的样子:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){
self.view = corePlotContent.view; //make graph the landscape view
self.view.transform = CGAffineTransformMakeRotation(deg2rad*(-360));
self.view.bounds = CGRectMake(0.0, 0.0, 1024.0, 748.0);
}else{
self.view = portraitView;
self.view.transform = CGAffineTransformMakeRotation(0);
self.view.bounds = CGRectMake(0.0, 0.0, 768.0, 1004.0);
}
}

我想我需要覆盖“willAnimateRotationToInterfaceOrientation”方法并在那里添加一些动画,但我不确定如何编写代码。我之前没有制作任何动画,所以我没有取得任何进展。谁能帮帮我,谢谢!

最佳答案

方法:willRotateToInterfaceOrientation:duration: 在用户界面开始旋转之前调用,它用于准备旋转 View - 在过渡动画发生之前设置 View 状态。

基本上,您不需要重写此方法,除非您想禁用 View 交互、停止媒体播放,或者在 View 转换动画期间暂时关闭昂贵的绘图或实时更新。此方法不会在动画 block 中调用

相反,您应该使用 willAnimateRotationToInterfaceOrientation:duration: 方法。此方法从用于旋转 View 的动画 block 内调用 - 在此调用内所做的每个视觉属性更改都将正确设置动画。

希望这能解决您的问题。

关于objective-c - 旋转 Ipad 时动画 View 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5343028/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com