gpt4 book ai didi

ios - 需要有关 transitionFromView :toView:duration:options:completion: 的帮助

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

关于 transitionFromView:toView:duration:options:completion: Apple 文档在最后几行中这样说:

This method modifies the views in their view hierarchy only. It does not modify your application’s view controllers in any way. For example, if you use this method to change the root view displayed by a view controller, it is your responsibility to update the view controller appropriately to handle the change.

如果 ViewController 有 2 个全屏大小的 View ,一次显示一个,则没有问题:

[transitionFromView:self.view toView:self.view2...

但这意味着您有责任适本地更新 View Controller 以处理更改

如果我这样做:

secondViewController *sVc = [[secondViewController alloc]init];
[transitionFromView:self.view toView:sVc.view...

我如何负责适本地更新 View Controller 以处理更改?或者如何更新 ViewController?

更新

我创建了一个单一 View 项目,添加了 secondVC,然后在 firstVC 中点击按钮,我这样做了:

self.svc = [[secondVC alloc]init]; 

[UIView transitionFromView:self.view toView:self.svc.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {}];

... secondVC viewDidLoad 正在运行,它的 nslog 正在运行。

那么如何处理viewcontroller的更新呢?

最佳答案

声明“您有责任适本地更新 View Controller 以处理更改。”这意味着您必须适本地调用 View 层次结构委托(delegate)方法,例如:

- (void)viewDidLoad;
- (void)viewDidUnload;
- (void)viewWillAppear;
- (void)viewDidDisappear;

以及负责适当 View 管理的其他方法。

这是 some examples .

关于ios - 需要有关 transitionFromView :toView:duration:options:completion: 的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16337706/

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