关闭 UIScrollView 底层的模态视图更改

Dismiss modal view changes underlying UIScrollView(关闭 UIScrollView 底层的模态视图更改)
本文介绍了关闭 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.

看看你的 viewWillAppearWillDisappearDidAppear...如果合适的话,即使是 LoadUnload ,尽管不太可能在模态中没有任何内容的情况下为您的琐碎测试调用它们.尝试在这些方法中添加一些日志,看看调用了哪些方法.

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.

您是说这些方法中没有自定义代码,或者您的控制器根本没有覆盖它们?可以有所作为.

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 底层的模态视图更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)