美文网首页
tabBar的代理对象不可修改特性

tabBar的代理对象不可修改特性

作者: 小苗晓雪 | 来源:发表于2017-04-05 16:08 被阅读292次

    call stack调用堆栈错误信息输出如下:

    tabBar调用堆栈的错误信息输出.png

    UITabBar的代理对象是他自身的控制器,这是系统写好的!也是不可修改的!
    如果一个控制器继承自UITabBarController , 那么这个控制器自动就成为了tabBar的代理对象 , 所以不用进行设置就可以直接敲出想要的代理方法 ;

    Terminating app due to uncaught exception 'NSInternalInconsistencyException',
     reason:
        'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.'
        //改变被tabBarController所管理的tabBar的代理是不允许的 ;
    

    UITabBar的 代理方法:

    @protocol UITabBarDelegate<NSObject>
    @optional
    //点击item 即系统私有的这个类:(tabBarButton)的方法:⭐️⭐️⭐️⭐️⭐️
    - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item; // called when a new view is selected by the user (but not programatically)
    
    /* called when user shows or dismisses customize sheet. you can use the 'willEnd' to set up what appears underneath. 
     changed is YES if there was some change to which items are visible or which order they appear. If selectedItem is no longer visible, 
     it will be set to nil.
     */
    
    - (void)tabBar:(UITabBar *)tabBar willBeginCustomizingItems:(NSArray<UITabBarItem *> *)items __TVOS_PROHIBITED;                     // called before customize sheet is shown. items is current item list
    - (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray<UITabBarItem *> *)items __TVOS_PROHIBITED;                      // called after customize sheet is shown. items is current item list
    - (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray<UITabBarItem *> *)items changed:(BOOL)changed __TVOS_PROHIBITED; // called before customize sheet is hidden. items is new item list
    - (void)tabBar:(UITabBar *)tabBar didEndCustomizingItems:(NSArray<UITabBarItem *> *)items changed:(BOOL)changed __TVOS_PROHIBITED;  // called after customize sheet is hidden. items is new item list
    
    @end
    
    NS_ASSUME_NONNULL_END
    
    

    愿编程让这个世界更美好

    相关文章

      网友评论

          本文标题:tabBar的代理对象不可修改特性

          本文链接:https://www.haomeiwen.com/subject/zzfxattx.html