IPhone API Communication

I've always been confused about the strange communication in the iPhone API - specifically with the UIViewController, which has hardcoded references to UITabBarItem, UITabBarController, etc.

So, you add a UIViewController to the UITabBarController, which in turn asks the UIViewController for what should be displayed on the UITabBar (via the UIViewController tabBarItem property).

Why doesn't it go UITabBarController-> UITabBarItem-> UIViewController? It seems so obvious.

Does anyone else think this is disgusting?

0


source to share


1 answer


UITabBarItem is actually more of a button than anything else. This is what you click to select a tab. Since it is a button, it does not need to "own" the displayed UIViewController. Instead, it sends a message to the UITabBarController to switch to the UIViewController as indicated by the selected tab item.



Also, be careful with the term "hardcoded". The use of this term means that the values ​​cannot be changed. In the case of UITabBarController, these are properties that CAN and DO change.

+2


source







All Articles