在this示例。动画UIView框架,子视图UIScrollView并不总是动画
我在制作tabBarController(用于全屏效果)时设置了PhotoViewerViewController的框架动画效果。 PhotoViewer使用uiscrollview生成Apple的照片应用程序所具有的相同效果。无论出于何种原因,它有时会与我的PhotoViewer框架一起动画,有时它不会。
您可以在第一个示例中看到它在增加帧大小时跳转,但在减小帧大小(并恢复标签栏)时可以很好地进行动画处理。
但是,在this示例中,当照片是垂直的时,它会在两个方向上跳跃。
在这两种情况下,如果我使用滚动视图放大照片,它会在两个方向上正确地进行动画。
我知道有证据,但我不能把手指放在这里发生的事情上。
这里是我的动画块:
void (^updateProperties) (void) =^{
self.navigationController.navigationBar.alpha = hidden ? 0.0f : 1.0f;
self.navigationController.toolbar.alpha = hidden ? 0.0f : 1.0f;
if (self.tabBarController) {
int height = self.tabBarController.tabBar.bounds.size.height;
for(UIView *view in self.tabBarController.view.subviews)
{
int newHeight;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UIInterfaceOrientationIsPortrait(orientation)) {
newHeight = hidden ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.height - height;
} else {
newHeight = hidden ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.width - height;
}
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, newHeight, view.frame.size.width, view.frame.size.height)];
}
else
{
CGRect newFrame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, newHeight);
[view setFrame:newFrame];
// update our VC frame with animation
[self.view setFrame:newFrame];
}
}
}
};
代码改编自一个职位上SO:UITabBar wont hide
上github全部来源。
谢谢。后者不起作用,但我会放弃前者。 –
虽然我还没有解决它,但我认为你已经指出了我的正确方向。我不确定是否在PhotoImageView本身或包含它的滚动条上触发了此特定转换。 –
就我个人而言,我会移动所有将scrollview的内容集中到scrollview子类本身的逻辑。在那里,您可以覆盖-setContentOffset:执行布局,而不是使用缩放委托方法。 – hatfinch