iPhone UITabBarController [英] iPhone UITabBarController

查看:76
本文介绍了iPhone UITabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有3个项目的UITabBarController,如果我在第二个或第三个选项卡上,我很好奇如何从第一个选项卡访问方法。我遇到的问题是我在第一个选项卡上有一个UIImageView,它使用核心动画连续循环显示3张图像。但是,当我切换到第二个选项卡并尝试切换回第一个选项卡时,程序将挂起。我发现如果我停止动画,那么它将使我切换回第一个选项卡。有任何想法吗?

I am using a UITabBarController with 3 items and am curious how to access a method from the first tab if I am on the second or third tab. The problem I am running into is I have a UIImageView on the first tab that is using core animation to loop continuously through 3 images. But when I switch to the second tab and try to switch back to the first tab the program hangs. I discovered if I stop the animation then it will let me switch back to the first tab fine. Any ideas?

推荐答案

您可以使用UITabBarController的 viewControllers 属性(返回控制器数组)并通过其索引获取所需的内容。

但是,更好的方法是尝试在控制器的 -viewWillDisappear中停止动画:方法并在 -viewWillAppear:中恢复动画。

You can access view controllers in UITabBarController using its viewControllers property (returns array of controllers) and get the one you need by its index.
The better way, however, is to try to stop animations in controller's -viewWillDisappear: method and resume animations in -viewWillAppear: .

这篇关于iPhone UITabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆