当自己写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
本文介绍了在iOS开发中,当开发者同时实现UITabBarControllerDelegate与UITabBarDelegate时,导致UITabBarDelegate方法优先执行而忽视UITabBarControllerDelegate方法的问题,并提供了解决策略。

4372

被折叠的 条评论
为什么被折叠?



