gpt4 book ai didi

ios - 自定义 Segue Flash

转载 作者:行者123 更新时间:2023-12-01 15:51:14 25 4
gpt4 key购买 nike

我正在使用以下代码覆盖自定义 segue 中的 perform 方法,以在 View Controller 之间移动时实现滑动效果。

- (void)perform
{
MasterController *sourceController = (MasterController *)self.sourceViewController;
MasterController *destinationController = (MasterController *)self.destinationViewController;

CGRect frame = sourceController.view.frame;

[sourceController.view addSubview:destinationController.view];
[destinationController.view setFrame:CGRectOffset(frame, frame.size.width, 0)];

[UIView animateWithDuration:0.5 animations:^{

[sourceController.view setFrame:CGRectOffset(frame, -frame.size.width, 0)];

} completion:^(BOOL finished) {

[sourceController presentViewController:destinationController animated:NO completion:nil];
[destinationController.view removeFromSuperview];

}];
}

与此代码类似的代码遍布整个互联网。问题是“有时”在动画完成后屏幕闪烁/闪烁/闪烁然后恢复正常。

删除 [destinationController.view removeFromSuperview]; 行代码似乎可以解决问题。但是,这看起来不对!对吧?

有什么解决办法吗?

最佳答案

是的,只需删除 [destinationController.view removeFromSuperview];。它将为您完成。在 segue 结束时,destinationController.view 将拥有一个新的 super View ,并将从 sourceController.view 中删除。

关于ios - 自定义 Segue Flash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30098605/

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