gpt4 book ai didi

ios - 防止 contentSizeForViewInPopover 设置动画

转载 作者:行者123 更新时间:2023-11-28 20:33:09 25 4
gpt4 key购买 nike

我有一个包含 UITableView 的弹出窗口。在 Storyboard 中,我将弹出窗口的高度设置为适合整个表格,并且显示效果很好。但是,在某些情况下我需要显示较少的单元格,在这些情况下我想更改弹出窗口的高度。我这样做:

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (trimFourCells) { // reduce the popover's height by that of four cells
CGSize size = self.contentSizeForViewInPopover;
size.height -= 4*60;
self.contentSizeForViewInPopover = size;
}
}

效果很好,除了变化是动画的:首先显示全尺寸,然后在大约一秒钟内缩小。

我的问题是这个动画是否可以被禁用。

我曾尝试在 [super viewDidAppear:animated] 中传递 NO,甚至尝试在大小更改后移动该行。它没有阻止动画。然后我尝试将代码移动到 viewWillAppear,这甚至没有改变高度。

最佳答案

感谢@frowing,这是解决方案。不必在弹出窗口的代码中更改大小,而必须在调用者中完成。我已将如下代码添加到 prepareForSegue:

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
UIPopoverController *pc = ((UIStoryboardPopoverSegue*)segue).popoverController;
if (trim_nCells > 0) { // trim that many cells from the table
CGSize size = pc.contentViewController.contentSizeForViewInPopover;
size.height -= trim_nCells * cellHeight;
[pc setPopoverContentSize:size animated:NO];
}
(... rest of the prep code ...)
}

请注意,由于它是在显示之前完成的,因此不涉及动画,因此 animated: 参数的值无效。

关于ios - 防止 contentSizeForViewInPopover 设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11528907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com