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

标签 ios objective-c uiview

关于 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/

相关文章:

iOS TESSERACT : Disable Dictionary

ios - 如何使用 UIWebView 或 WKWebView 在后台连续播放音乐

ios - 如何使用UIAppearance设置UIPickerView的背景颜色?

objective-c - 从图像获取“时间戳”

iphone - 绘制 UIImage 的选定区域

ios - SceneKit 添加地板崩溃

ios - 在应用程序中找不到 'Folder referenced' 文件

ios - 重新启动 objective-c 中的对象 - Matchismo 作业 2 - 重新启动游戏

ios - 覆盖 drawRect :(CGRect)rect in Objective-C (iOS)?

ios - 插页式广告的 iAd 自定义过渡