2012-04-03 7 views
-1

私は、tabviewcontroller.viewにサブビューとしてUiimageviewを追加しています。私が他のビューコントローラにプッシュするとtabbarcontrollerは隠されますが、画像は他のクラスにプッシュして表示されています。tabbarcontrollerのすべてのタブバーアイテムはナビゲーションコントローラです。私はここでtabbarcontroller 内タブバーを追加didntは私のコードです:他のView Controllerにプッシュされたときにuiimageを非表示にする

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]; 
[email protected]"TrackProgram"; 
tabItem1.view.backgroundColor=[UIColor clearColor]; 


TrackClinic_iPhone *loc = [[TrackClinic_iPhone alloc] init]; 
UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController:loc] autorelease]; 
[email protected]"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]; 

}

+0

[Hiding Imageview](http://stackoverflow.com/questions/9989224/hiding-imageview)のダブル投稿 – jrturton

答えて

0

を押したとき、私はあなたの古い質問をコメント。

Hiding Imageview

beacuse hidesBottomBarWhenPushed = yesがあなたのtabBarController非表示タブバーが表示されない意味しています。

imageViewにタブバーでは表示できないように注意する必要があります。

このメソッドは、操作プッシュまたはポップオブジェクトコントローラの場合、メッセージtabBarController.tabBarサブビューに送信することもできます。

あなたのimgVはタブバーに追加されます。ここに例を示します。

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

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

が、慎重にtabBarController.tabBar高さ、大きさの異なるtabBarController.view

ので、あなたのフレームはサイズや座標を設定する必要があります。

+0

私はtabviewcontroller.tabarに画像ビューを追加しました。もし私がそれを好きなら、イメージ自体は現れません。 – user1125799

+0

あなたは([self.view subviews]のUIImageView *ビュー)を削除していますか? {(UIImage * img in view.subviews){//サブビューから写真を削除します [img removeFromSuperview]; } [ビューremoveFromSuperview]; }]このコード。あなたのプロジェクトを再試行しますか? –

+0

はい。試しました。変更はありません。再び画像が表示されます。 – user1125799

関連する問題