2012-04-03 56 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 

}