1.未清除原来子控件
-(void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];
for (UIView *child in self.tabBar.subviews) {
if ([child isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[child removeFromSuperview];
}
}
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// 移除之前的4个UITabBarButton
for (UIView *child in self.tabBar.subviews) {
if ([child isKindOfClass:[UIControl class]]) { //UITabBarButton
[child removeFromSuperview];
}
}
}
-(void)DeletemoreMore{
for (UIView *child in self.tabBar.subviews) {
if ([child isKindOfClass:[UIControl class]]) { //UITabBarButton
[child removeFromSuperview];
}
}
}
2.rootViewController title命名原因,应为self.navigationItem.title = @"***";而非self.title = @"***";
网友评论