滚动页面滚动视图时,动画期间不显示ModalViewController
我的应用程序有分页滚动视图。 scrollview的每个页面都有一个视图控制器实例(buttonViewController),它显示了一个按钮网格。如果用户单击其中一个按钮,buttonViewController将以模态方式启动detailViewController,并将动画设置为YES。
My application has a paged scrollview. Each page of the scrollview has an instance of a view controller (buttonViewController) that shows a grid of buttons. If the user clicks on one of the buttons, buttonViewController launches a detailViewController modally, with animation set to YES.
如果我正在查看第一页(最左边)或滚动视图,一切正常。但是,如果我滚动到任何其他页面,则不会出现模态视图动画(在这种情况下从底部向上滑动)。相反,整个视图在与动画运行时相同的时间内变黑,然后模态视图控制器显示完全显示。解雇模态视图控制器时会发生同样的事情。
If I'm viewing the first page (furthest left) or the scroll view, everything work's correctly. However, if I am scrolled to any of the other pages, the modal view animation (sliding up from the bottom in this case) doesn't appear. Instead, the whole view goes black for the same length of time that the animation would run for, and then the modal view controller appears fully displayed. The same thing happens when dismissing the modal view controller.
代码完全是标准的。在我的buttonViewController中,我调用:
The code is completely standard. In my buttonViewController I call:
[self presentModalViewController:detailController animated:YES];
无论我正在查看哪个页面,相同的代码都会运行(尽管在buttonViewController的不同实例上当然。)
The same code runs no matter which page I'm looking at (though on different instances of buttonViewController of course.)
我将如何开始调试?
这可能与detailController的框架有关...当你在UIScrollView中时,第一页在0到320之间,但是当你滚动那个偏移增量时,所以(假设你有全屏页面)下一个视图将是320和640,下一个将是640和(640 + 320),依此类推。因此,当您使用框架CGRectMake(0,0,320,460)设置detailController时,当您在第一页时,动画看起来会很好,但是当您在任何其他页面时,动画将在(0,0)处进行然后我猜测viewcontroller看到这不是活动屏幕,并将模态视图控制器移动到活动屏幕所在的位置。如果你像这个CGRectMake初始化你的框架(320 * pageNumber,0,320,460)我认为你将有你想要的行为。让我知道这是否真的很好奇我自己。
This might have to do with the frame of the detailController...When you are in a UIScrollView, the first page is between 0 and 320, however when you scroll that offset increments, so (assuming you have full screen pages) the next view will be 320 and 640, the next one will be in 640 and (640+320), and so on and so forth. So when you are setting up your detailController with frame CGRectMake(0,0,320,460), when you are in the first page, the animation will look fine, but when you are in any other page the animation will take place at (0,0) and then im guessing the viewcontroller sees this is not the active screen a nd moves the modal view controller to where the active screen is. If you initialize your frame like this CGRectMake(320*pageNumber,0,320,460) I think youll have the d esired behavior you are looking for. Let me know if this works im curious myself.