跳转到uitabbarController时出现了下面的BUG
我的部分代码如下:
equipmentViewController * equip=[[equipmentViewController alloc]init];
myNavigationController *nav3=[self NavigationControllerWithviewController:equip title:@"服务" image:@"fuwu@2x" selectedImage:@"fuwuselected@2x"];
settingViewController * set=[[settingViewController alloc]init];
myNavigationController *nav4=[self NavigationControllerWithviewController:set title:@"设置" image:@"shezhi@2x" selectedImage:@"shezhiselected@2x"];
self.viewControllers=@[nav,nav1,nav2,nav3,nav4];
后来经过测试,把uitabbarController添加子视图的方法由self.viewControllers=@[nav,nav1,nav2,nav3,nav4];改成 [self addChildViewController:nav];(剩下的我就不一一写出来了)就好了。
equipmentViewController * equip=[[equipmentViewController alloc]init];
myNavigationController *nav3=[self NavigationControllerWithviewController:equip title:@"服务" image:@"fuwu@2x" selectedImage:@"fuwuselected@2x"];
settingViewController * set=[[settingViewController alloc]init];
myNavigationController *nav4=[self NavigationControllerWithviewController:set title:@"设置" image:@"shezhi@2x" selectedImage:@"shezhiselected@2x"];
// self.viewControllers=@[nav,nav1,nav2,nav3,nav4];
[self addChildViewController:nav];
[self addChildViewController:nav1];
[self addChildViewController:nav2];
[self addChildViewController:nav3];
[self addChildViewController:nav4];
解决UITabBarController BUG
本文介绍了一种解决在iOS应用中使用UITabBarController时出现的BUG的方法。通过更改添加子视图控制器的方式,从使用viewControllers属性改为逐个调用addChildViewController方法,有效地解决了遇到的问题。
1614

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



