Hiding Imageview

*爱你&永不变心* 提交于 2019-12-13 05:29:55

问题


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;

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

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

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

}


回答1:


beacuse hidesBottomBarWhenPushed=yes is mean your tabBarController hide tabbar not view.

Be a point of caution, you will need to add to imageView in tabBar not view.

maybe this method send to message tabBarController.tabBar subviews, when a operate push or pop object controller.

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

but carefully tabBarController.tabBar height-size different tabBarController.view

so, you frame should set size or coordinates.




回答2:


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

}


来源:https://stackoverflow.com/questions/9989224/hiding-imageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!