Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone UITabBarController

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?

like image 548
dbslone Avatar asked May 24 '26 14:05

dbslone


1 Answers

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: .

like image 53
Vladimir Avatar answered May 27 '26 04:05

Vladimir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!