[ios]UITabBarController 的UITabBarControllerDelegate 与UITabBarDelegate冲突

当自己写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 会被优先执行。且 后者不被执行

猜你喜欢

转载自poolo.iteye.com/blog/1833828