2012-04-03 5 views
-1

Ich füge Uiimageview als Unteransicht zu tabbarcontroller.view hinzu. Wenn ich auf andere Ansicht schob Controller Tabbarcontroller wird versteckt, aber das Bild erscheint beim Drücken auf andere Klasse. Innerhalb der Tableiste Controller ist das gesamte Tabbar-Element ein Navigationscontroller. Ich habe nicht Tabbar im Inneren des TabBarController hinzufügen Hier ist mein Code:Ausblenden von uiimage, wenn zu anderem View-Controller geschoben

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

wenn ich Pushed andere Klasse

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

Doppelpfosten von [Hiding Imageview] (http://stackoverflow.com/questions/9989224/hiding-imageview) – jrturton

Antwort

0

ich Ihre ältere Frage Stellung zu nehmen.

Hiding Imageview

beacuse hidesBottomBarWhenPushed = yes ist bedeuten, dass Ihre TabBarController verstecken Tabbar sehen nicht.

Seien Sie vorsichtig, Sie müssen ImageView in tabBar nicht anzeigen hinzufügen.

vielleicht diese Methode an Nachricht tabBarController.tabBar Subviews senden, wenn ein Push-oder Pop-Objekt-Controller.

so, Ihre imgV hinzufügen Tableiste. hier zum Beispiel.

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

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

aber sorgfältig tabBarController.tabBar höhen Größe unterschiedliche tabBarController.view

so, Sie setzen Größe oder Koordinaten Rahmen sollte.

+0

Ich habe versucht, indem ich die imageview zu meiner tabbarcontroller.tabar hinzufügen. Wenn mir das gefällt, erscheint das Bild selbst nicht. – user1125799

+0

sind Sie [für (UIImageView * Blick in [self.view Subviews]) { für (UIImage * img in view.subviews) entfernen {// entfernen photoes vom subview [img removeFromSuperview]; } [view removeFromSuperview]; }] dieser Code. Versuchen Sie Ihr Projekt erneut? –

+0

ja. Ich habe es versucht. aber keine Veränderung. wieder erscheint das Bild. – user1125799

Verwandte Themen