动态调整popover大小时阻止动画 [英] Prevent animation when dynamically resizing popover

查看:122
本文介绍了动态调整popover大小时阻止动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我自己意识到这一点并找到了答案以确认:

So I realized this myself and found this answer to confirm:

从动画中阻止contentSizeForViewInPopover

基本上我在类似的船上,因为我想动态调整我的popover,具体取决于多少数据我必须显示。我也在弹出视图移动到位的情况下进行此动画操作。问题是,我无法在调用者/父级中设置popover的内容大小,因为在调用viewDidAppear或viewDidLayoutSubviews之前,文本视图的内容视图的大小和弹出框中的文本视图的框架都是已知的,但是当然在这一点上已经太晚了,弹出窗口已经开始可见了,因此我得到了这个不受欢迎的动画。

Basically I am in a similar boat in that I want to dynamically resize my popover, depending on how much data I have to display. I am also getting this animation action where the popover view moves into place. The problem is, I can't set the popover's content size in the caller/parent, because neither the size of the content view for the text view nor the frame for the text view in my popover is known until viewDidAppear or viewDidLayoutSubviews is called, but of course at this point it's too late, the popover is already on its way to being visible, thus I am getting this unwanted animation.

我在弹出视图控制器类中动态设置文本视图的大小以适应文本视图显示的数据量,这仅适用于此点它们的帧大小是定义/已知的/然而你想在视图生命周期中尚未达到那个点的时候说出来。

I am dynamically setting the size of the text views in the popover view controller class to fit the amount of data the text views are displaying, and this only works at the point where their frame size is defined/known/however you want to word it when it hasn't gotten to that point yet in the view lifecycle.

我应该提到我拥有我的视图控制器并在故事板中查看所有内容。

I should mention that I have my view controllers and view all done in a storyboard.

这有意义吗?希望我能解释清楚。非常感谢任何帮助或建议。

Does this make sense? Hope I'm explaining it well. Any help or suggestions greatly appreciated.

编辑这是我在view-controller中的viewDidLayoutSubviews方法我在popover中加载 - 希望这清楚地说明了这一点。第一次加载,如果我没有在viewDidLayoutSubviews或viewDidAppear中执行此操作,我的2个文本视图的框架是CGRectZero,文本视图不会正确调整内容大小并且弹出窗口大小也不正确:

EDIT Here is my viewDidLayoutSubviews method from the view controller I am loading in the popover - hopefully this makes it clear. The first time this loads, if I don't do this in viewDidLayoutSubviews or viewDidAppear the frame for my 2 text views are CGRectZero, the text views don't resize for the content correctly and the popover size isn't right either:

- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];

self.physicianDataNewValueTextView.text = self.physicianDataNewValue;
CGRect frame = self.physicianDataNewValueTextView.frame;
frame.size.height = self.physicianDataNewValueTextView.contentSize.height;
self.physicianDataNewValueTextView.frame = frame;

self.physicianDataOldValueTextView.text = self.physicianDataOldValue;
frame = self.physicianDataOldValueTextView.frame;
frame.size.height = self.physicianDataOldValueTextView.contentSize.height;
self.physicianDataOldValueTextView.frame = frame;

self.contentSizeForViewInPopover = CGSizeMake(384.0f, self.physicianDataOldValueTextView.frame.size.height + 75.0f);
}


推荐答案

所以我决定使用委托。我没有在视图控制器中为弹出窗口重置内容大小,而是使用新大小调用我的委托(包含视图控制器),因此我可以将动画属性设置为NO来设置它。效果很好。

So I decided to use delegation. Instead of resetting the content size in the view controller for the popover, I call my delegate (which is the containing view controller) with the new size so I can set it there with the animated property set to NO. Works well.

这篇关于动态调整popover大小时阻止动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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