iOS 【错误:'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.'】
来源:互联网 发布:java开源视频播放 编辑:程序博客网 时间:2024/04/30 14:40
错误:'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; 所以这句话写在这里是错误的,上面已经解释
1 0
- iOS 【错误:'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.'】
- How to hide/show tab bar of a view with a navigation bar in iOS?
- Simple Tab-bar Controller
- iOS 5.0 load tab bar controller
- iOS学习- 05 Tab Bar Controller
- iOS之tab bar
- 如何隐藏Tab Bar Controller的Tab Bar
- iOS开发使用Tab Bar Controller实现页面导航功能
- Tab Bar Controller(选项卡)的使用
- tab bar controller 代码使用例子
- 使用Tab Bar Controller 切换视图
- 标签栏视图控制器(Tab Bar Controller)
- AKTabBarController is an adaptive and customizable tab bar for iOS
- Attempting to load the view of a view controller while it is deallocating is not allowed and may res
- Attempting to load the view of a view controller while it is deallocating is not allowed and may res
- A Wyckoff Bar-by-Bar Analysis Example
- Hiding the iPhone Tab Bar With TTNavigator
- Manual commit is not allowed over a Spring managed
- 【iOS】GCD死锁
- if 语句里面有 return;
- e.preventDefault()与e.stopPropagation()的区别
- Spring MVC —— 整体结构
- 设计模式-结构型模式汇总
- iOS 【错误:'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.'】
- 一个写日志的方法
- java常用算法之最长回文子串(Longest Palindromic Substring)
- 快速理解Docker - 容器级虚拟化解决方案
- java的xpath语法
- if语句 return;结尾
- Java注解全面解析
- [案例]某体育用品公司在零售领域BI的产品应用解决方案
- Windows Server 2008最大内存限制