解决方法:在自定义tabbar这个类的-(void)viewWillAppear:(BOOL)animated;
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
for(UIView* view in self.tabBar.subviews)
{
if(![viewisKindOfClass:[TabBar class]]) {
[viewremoveFromSuperview];
}
}
}
可能不会成功,在主要的视图layoutSubView中再删除一次,以防出现的时候不能删除,在viewWillAppear中删除只是保证删除一次
所以要进行多次删除
-(void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
for(UIView * viewin self.tabBar.subviews)
{
if(![view isKindOfClass:[TabBar class]]) {
[view removeFromSuperview];
}
}
}
网友评论