zoukankan      html  css  js  c++  java
  • iOS开发中的错误整理,Changing the delegate of a tab bar managed by a tab bar controller is not allowed

    iOS 【错误:'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.'】

    • 错误:'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.'
    • 意为不允许修tabBar的delegate属性
    • 产生原因:设置代理的这句代码写在了 为 tabBarController 的 tabBar属性 赋值之后看一下错误产生的代码:(共三行正确代码,其余的是个人理解)
        // 我们想要利用KVC替换掉UITabBarViewController自带的tabBar属性
        // self.tabBar  这个属性是属于我们的UITabBarController的,不是我们自己创建的属性
        // 此处的关键在于path后面跟的是属性名,而前面的value是为这个属性赋得值
    
        WZYTabBar *tabBar = [[WZYTabBar alloc] init];
    
        // 设置代理的这句代码不能写在为tabBarController的tabBar属性赋值之后,不然会报错:
        // 'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.' 意为不允许修改tabBar的delegate属性(此时的tabBar是被tabBarController所管理的)
        // ★ 所以要重写覆盖系统自带的东西,我们先把该设置的设置完再覆盖上去。(因为系统自带的东西一般是不让去修改的,一般是readOnly的)
    
        tabBar.delegate = self;
    
        // 这句代码设置过后,tabBar的delegate就是WZYTabBarViewController,所以这句话过后就不能再修改tabBar的delegate属性了
    
        [self setValue:tabBar forKeyPath:@"tabBar"];
    
    //    tabBar.delegate = self;  所以这句话写在这里是错误的,上面已经解释  
    
  • 相关阅读:
    ASP.NET MVC 扩展相关
    新.NET开发十大必备工具
    c#调用存储过程两种方法
    TweakUI取消pc喇叭声
    baidu mp3竟然还加密,太扯了
    NTLM在使用代理服务器的情况下,第三次握手可能出错
    httpclient解析gzip网页
    eclipse不能自动编译工程的解决方法
    bat设置环境变量
    java的ZipOutputStream压缩文件的两个问题(乱码和每次zip后文件md5变化)
  • 原文地址:https://www.cnblogs.com/gchlcc/p/5725286.html
Copyright © 2011-2022 走看看