当推送到其他视图控制器时隐藏uiimage

时间:2012-04-03 08:26:15

标签: iphone uiimage uitabbarcontroller

我将Uiimageview作为子视图添加到tabbarcontroller.view。当我推到其他视图控制器tabbarcontroller被隐藏但图像出现时推送到其他类。在tabbarcontroller内部所有tabbar项目是导航控制器。我没有在tabbarcontroller中添加tabbar  这是我的代码:

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];
[imgV release];



Dashboard_iPhone *dash = [[Dashboard_iPhone alloc] init];
UINavigationController *tabItem0 = [[[UINavigationController alloc] initWithRootViewController:dash] autorelease];
tabItem0.view.backgroundColor=[UIColor clearColor];

    TrackProgram_iPhone *rep = [[TrackProgram_iPhone alloc] init];
UINavigationController *tabItem1 = [[[UINavigationController alloc] initWithRootViewController:rep] autorelease];
tabBarController.tabBarItem.title=@"TrackProgram";  
tabItem1.view.backgroundColor=[UIColor clearColor];


TrackClinic_iPhone *loc = [[TrackClinic_iPhone alloc] init];
UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController:loc] autorelease];
tabBarController.tabBarItem.title=@"TrackClinic ";
tabItem2.view.backgroundColor=[UIColor clearColor];



tabBarController.viewControllers=[NSArray arrayWithObjects:tabItem0,tabItem1,tabItem2,nil];


[self.view insertSubview:tabBarController.view belowSubview:dash.view ];    

[self presentModalViewController:tabBarController animated:NO];

当我推到其他班级时

    -(void)logoutBtnTap
{
appDelegate.enterLogout=YES;
for(UIImageView *view in[self.view subviews])

{
    for(UIImage *img in view.subviews){//remove photoes from the subview
        [img removeFromSuperview]; 
    }
    [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 个答案:

答案 0 :(得分:0)

我评论你的旧问题。

Hiding Imageview

beacuse hidesBottomBarWhenPushed = yes表示你的tabBarController隐藏标签栏不能查看。

请注意,您需要在tabBar中添加到imageView而不是视图。

当操作push或pop对象控制器时,也许这个方法发送到消息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

所以,你的框架应该设置尺寸或坐标。

相关问题