2012-04-03 60 views
0

我将uiimageview作为子视图添加到tabbarcontroller.view。当我推到其他viewcontroller tabbar得到隐藏,但图像添加到tabbarcontroller出现。 请帮我在推送到其他视图控制器时删除imageview。隐藏Imageview

 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;

UIImage *img = [UIImage imageNamed: @"home_selected.png"]; 
[imgV setImage:img]; 
// [imgV setAlpha:0.5]; 

[self.tabBarController.view addSubview:imgV]; 
[self.tabBarController.view bringSubviewToFront:imgV]; 

当推到其他视图 - 控制

-(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]; 

}

回答

0

怎么一回事,因为hidesBottomBarWhenPushed=yes是意味着你tabBarController隐藏的TabBar无法查看。

请注意,您需要在tabBar中添加imageView才能查看。

也许这种方法发送到消息tabBarController.tabBar子视图,当一个操作推或弹出对象控制器。

所以,你的imgV添加到tabbar。这里例如。

UIImage *img = [UIImage imageNamed: @"home_selected.png"]; 
[imgV setImage:img]; 

[self.tabBarController.tabBar addSubview:imgV]; 
[self.tabBarController.tabBar bringSubviewToFront:imgV]; 

但仔细tabBarController.tabBar高度尺寸不同tabBarController.view

所以,你应该帧的大小设置或坐标。

1
for(UIImageView *view in[self.view subviews]) 

{ 
    for(UIImage *img in view.subviews){//remove photoes from the subview 
    [img removeFromSuperview]; 
} 
    [view removeFromSuperview];//remove uiimageview from the main view 

}