问题描述
我正在将uiimageview作为子视图添加到tabbarcontroller.view.当我推到其他viewcontroller标签栏时被隐藏,但是出现了添加到tabbarcontroller的图像.请帮助我删除图像视图,同时推动其他视图控制器.
I am adding uiimageview as a subview to tabbarcontroller.view. when i pushed to other viewcontroller tabbar gets hided but the image added to the tabbarcontroller is appearing.Please help me to remove the imageviewwhile pushing to other viewcontroller.
imgV=[[UIImageView alloc]initWithFrame:CGRectMake(0, 428, 320, 48)];
tabBarController = [[UITabBarController alloc] init];
tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
tabBarController.moreNavigationController.topViewController.view.backgroundColor=[UIColor clearColor];
tabBarController.delegate=self;
//tabBarController.selectedIndex = 0;
// tabBarController.selectedIndex=0;
UIImage *img = [UIImage imageNamed: @"home_selected.png"];
[imgV setImage:img];
// [imgV setAlpha:0.5];
[self.tabBarController.view addSubview:imgV];
[self.tabBarController.view bringSubviewToFront:imgV];
推送到其他ViewController时
When pushing to other viewcontroller
-(void)logoutBtnTap
{
appDelegate.enterLogout=YES;
for(UIImageView *view in[self.view subviews])
{
[view removeFromSuperview];
}
Login_iPhone *controller=[[Login_iPhone alloc]init];
[controller setHidesBottomBarWhenPushed:YES];
[acctExec_iPhone.imgV removeFromSuperview];
acctExec_iPhone.imgV.hidden=YES;
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
推荐答案
是因为 hidesBottomBarWhenPushed = yes
意味着您的tabBarController隐藏了Tabbar而不是视图.
beacuse hidesBottomBarWhenPushed=yes
is mean your tabBarController hide tabbar not view.
请注意,您需要在tabBar而不是view中添加到imageView.
Be a point of caution, you will need to add to imageView in tabBar not view.
也许当操作推或弹出对象控制器时,此方法发送到消息tabBarController.tabBar子视图.
maybe this method send to message tabBarController.tabBar subviews, when a operate push or pop object controller.
因此,您的imgV添加到了标签栏.例如这里.
so, your imgV add to tabbar. here for example.
UIImage *img = [UIImage imageNamed: @"home_selected.png"];
[imgV setImage:img];
[self.tabBarController.tabBar addSubview:imgV];
[self.tabBarController.tabBar bringSubviewToFront:imgV];
但请小心tabBarController.tabBar高度-大小不同的tabBarController.view
but carefully tabBarController.tabBar height-size different tabBarController.view
因此,您应该设置框架的大小或坐标.
so, you frame should set size or coordinates.
这篇关于隐藏Imageview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!