我有一个UIView,我想在用户点击它时自动缩放成屏幕大小。为什么我的视图在旋转90度之前旋转?
我把代码http://cocoawithlove.com/2010/09/zoomingviewcontroller-to-animate-uiview.html
和变焦的作品,除变焦开始视图旋转90度之前。为什么会发生?
(该视图是一个传送带内。到用户敲击视图之前,装置被旋转到景观,在该点的转盘视图控制器被压入导航堆栈和显示的转盘。)
的代码是:
- (void)buttonTapped:(UIButton *) sender
{
NSInteger index = [self.carousel indexOfItemView:sender];
UIView *currentView = [self.carousel itemViewAtIndex: index];
UIView *proxyView = [[UIView alloc] initWithFrame:currentView.frame];
proxyView.hidden = YES;
proxyView.autoresizingMask = currentView.autoresizingMask;
[currentView.superview addSubview: proxyView];
CGRect frame = [currentView.window convertRect:currentView.frame fromView:proxyView.superview];
[currentView.window addSubview:currentView];
currentView.frame = frame;
[UIView
animateWithDuration:2.4
animations:^{
currentView.frame = currentView.window.bounds;
}];
(圆盘传送带是一个UIView派生对象,从https://github.com/nicklockwood/iCarousel)
由于
如果我注释掉的第一行,视图跳转到左下角(这是在中心),然后旋转。如果我注释掉第二行,它保持居中,但仍然旋转(但当然不会缩放)。 – Gruntcakes
@ ChrisP.Bacon解决方案,如文档中所解释的,如果存在非标识转换,则为“bounds”和“center”而不是“frame”制作动画。 – Caleb
旋转发生在动物之前,所以如果我完全注释掉动画代码,那么旋转仍然会发生。 – Gruntcakes