本文介绍了需要关于 transitionFromView:toView:duration:options:completion 的帮助:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 transitionFromView:toView:duration:选项:完成: Apple 文档在最后几行中说:

Regarding transitionFromView:toView:duration:options:completion: Apple doc says this in last few lines:

此方法仅修改视图层次结构中的视图.它确实不要以任何方式修改应用程序的视图控制器.为了例如,如果您使用此方法更改显示的根视图视图控制器,您有责任更新视图控制器适当地处理变化.

如果一个 ViewController 有 2 个全屏尺寸的视图,一次显示一个,则没有问题:

If a ViewController has 2 full screen size views display one at a time then no issues:

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

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

但这意味着什么您有责任适当地更新视图控制器以处理更改?

如果我这样做:

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

我如何负责适当地更新视图控制器以处理更改?或者如何更新 ViewController?

how its my responsibility to update the view controller appropriately to handle the change? or how to update ViewController?

更新

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

I created a single view projec, add secondVC then in firstVC on button tap i did this:

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

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

... secondVC viewDidLoad 正在工作,其 nslog 正在工作.

... secondVC viewDidLoad is working its nslog is working.

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

Then how to handle updating of viewcontroller?

推荐答案

声明您有责任适当地更新视图控制器以处理更改."这意味着您必须适当地调用视图层次结构委托方法,例如:

The statement "it is your responsibility to update the view controller appropriately to handle the change." it meant that you have to appropriately call view hierarchy delegate methods such as:

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

以及其他负责正确视图管理的方法.

And other methods that are responsible for proper view management.

这里有一些 示例.

这篇关于需要关于 transitionFromView:toView:duration:options:completion 的帮助:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 01:06