當自己寫UITabBarController 時候 如果 同時實現了UITabBarDelegate 與UITabBarControllerDelegate
willxxxx didxxxx時
UITabBarDelegate的會被調用而UITabBarControllerDelegate的不會被調用
故覆寫的時候不要同時實現同一個命名的方法。
ex:
- //UITabBarDelegate
- -(void)tabBar:(UITabBar *)tabBar didEndCustomizingItems:(NSArray *)items changed:(BOOL)changed{
- ……
- }
- //UITabBarControllerDelegate
- -(void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed{
- ……
- }
- 上面2個方法就不能同時複寫 否則後者無法被執行
根據看.h文件 是因爲UITabBarController 繼承自UIViewController <UITabBarDelegate, NSCoding>
然後消息分發的時候UITabBarDelegate 會被優先執行。且 後者不被執行
轉自
http://poolo.iteye.com/blog/1833828