关闭UIScrollView下的模式视图更改 [英] Dismiss modal view changes underlying UIScrollView

查看:119
本文介绍了关闭UIScrollView下的模式视图更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里必须有一些基本的东西。我打开了一个UIScrollView,它由客户UIScrollViewController(称为DataController)控制。在某个时间点,需要用户输入,所以我从DataController打开一个模态UIViewController:

There must be something basic that I am missing here. I have a UIScrollView open, which is controlled by a customer UIScrollViewController (called DataController). At a certain point in time, input from the user is needed, so I open a modal UIViewController from the DataController:

ElementSelectController *viewController = [[ElementSelectController alloc] initWithNibName:@"ElementSelectController" bundle:nil];
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
viewController.theDelegate = self;
[self presentModalViewController:viewController animated:YES];

一旦用户准备好了模态视图,它就会再次被解雇。这也发生在DataController中:

Once the user is ready with the modal view, it is dismissed again. This also happens from the DataController:

[self dismissModalViewControllerAnimated:YES];

一切正常。
但是当模态视图消失时,事实证明底层UIScrollView被调整为全屏,并滚动到位置(0,0)。即使是简单的模态视图也是如此,除了被忽略之外什么都不做。
显然,我希望UIScrollView保持与模态视图出现之前相同的状态和大小。

This all works fine. But when the modal view is gone, it turns out that the underlying UIScrollView is resized to full screen, and scrolled to position (0,0). This is the case even with a simple modal view that does not do anything else but be dismissed. Obviously, I want the UIScrollView to remain in the same state and size as it was before the modal view came up.

任何想法我做错了什么?

Any ideas what I am doing wrong?

我在设置UIScrollView框架时检查了堆栈跟踪(通过自定义UIScrollView的setFrame中的断点),看起来它是从:

I checked the stack trace when the UIScrollView frame is set (through a break-point in setFrame: of a custom UIScrollView), and it appears that it is called from:

-[UITransitionView transition:fromView:toView:]

通过dismissModalViewControllerAnimated调用来调用。

which is called via, via from the dismissModalViewControllerAnimated call.

推荐答案

-[UITransitionView transition:fromView:toView:]

完美正常,从模态转换回您的视图。这是动画等,如果您认为可以产生影响,请尝试使用动画模态。

Is perfectly normal for transitioning from the modal back to your view. This is the animation etc, try you modal with animation if you think that could make a difference.

看看你的 viewWillAppear WillDisappear DidAppear ...
即使是加载卸载如果合适的话,虽然不太可能在模态中没有任何内容的情况下调用那些琐碎的测试。
尝试在这些方法中放置一些日志来查看哪些被调用。

Take a look at your viewWillAppear, WillDisappear, DidAppear... Even the Load and Unload if appropriate, although unlikely those are called for your trivial test with nothing in the modal. Try placing some logging in those methods to see which is called.

你也说这些方法中没有自定义代码,或者你的控制器没有t完全覆盖它们?可能会有所作为。

Also are you saying there is no custom code in those methods, or your controller doesn't override them at all? Could make a difference.

这篇关于关闭UIScrollView下的模式视图更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆