gpt4 book ai didi

iOS:查看翻译动画。合适的方式。

转载 作者:行者123 更新时间:2023-11-29 03:26:14 25 4
gpt4 key购买 nike

我正在实现我自己的导航 Controller ,我正在伪造添加新 View 的动画,就像在 UINavigationContoller 中一样。

下面的代码效果很好,但是如果我移动 -addSubview:,在 UIView 动画调用之前,它会在 ios7 中设置动画,但在 ios6 中不会,问题是为什么? (我的意思是,为什么它会有所不同,因为动画将被异步安排和执行,对吗?或者我可能认为它会以某种方式影响动画的开始状态?)

- (void)didAddViewControllerInNavigationStack:(NSArray*)navigationStack
{
if (self.activeViewController) {
[self.activeViewController viewWillDisappear:YES];
[self.activeViewController viewDidDisappear:YES];
}

self.activeViewController = navigationStack.firstObject;
if (!self.activeViewController) return;


CGRect windowRect = [[UIScreen mainScreen] bounds];
windowRect.origin.x = windowRect.size.width;
self.activeViewController.view.frame = windowRect;


[self.activeViewController viewWillAppear:YES];

[UIView transitionWithView:self.view
duration:0.32
options:UIViewAnimationOptionCurveEaseOut
animations:^ { self.activeViewController.view.frame = [[UIScreen mainScreen] bounds]; }
completion:^(BOOL isDone){[self.activeViewController viewDidAppear:YES];}];

[self.view addSubview:self.activeViewController.view];
[UIView commitAnimations];


}

最佳答案

transitionWithView:duration:options:animations:completion: 的文档中,据说您应该在动画 block 中添加 subview :

The block you specify in the animations parameter contains whatever state changes you want to make. You can use this block to add, remove, show, or hide subviews of the specified view.

此外,您在调用 commitAnimations 时并未调用 beginAnimations:context:。你在这里混合东西。基于 block 的动画 API 不需要 begin-end API。

您的代码应该是:

[UIView transitionWithView:self.view
duration:0.32
options:UIViewAnimationOptionCurveEaseOut
animations:^ { [self.view addSubview:self.activeViewController.view]; self.activeViewController.view.frame = [[UIScreen mainScreen] bounds]; }
completion:^(BOOL isDone){[self.activeViewController viewDidAppear:YES];}];

关于iOS:查看翻译动画。合适的方式。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20436555/

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