Domanda

Ora sto sviluppando un'app che supporta i IOS 4.3 e 5.0.

Il mio codice funziona bene con 5.0, ma risulta in un bug trucco in 4.3.

Problema è:

Ho una vista con un tavolo in esso.Questa vista ha una barra di navigazione con elementi a barre di navigazione a sinistra ea destra.Una volta selezionata la riga in vista tabella (e raggiunge la sua vista corrispondente) e torna indietro, sia gli elementi della barra di navigazione sinistra che a destra "svaniscono".

Sono stato oltre questo casino per le ultime ore, qualcuno ha una cura?

Questo è quello che ho già fatto:

Questo è il metodo di utilità che chiamo quando viene visualizzata la vista.

+ (void)setNavigationBarContents:(UIViewController *)view 
{


UIImage *topBarimage=[UIImage imageNamed:NAVIGATION_BAR_IMAGE];


if([view.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {

    [view.navigationController.navigationBar setBackgroundImage:topBarimage forBarMetrics:UIBarMetricsDefault];
}
else 
{
    [view.navigationController.navigationBar insertSubview:[[UIImageView alloc] initWithImage:topBarimage] aboveSubview:view.navigationController.navigationBar];

}

UIImage *logo=[UIImage imageNamed:LOGO];
UIImageView *logoView=[[UIImageView alloc]initWithImage:logo];
view.navigationItem.titleView = logoView;

UIImage *settingsButtonImage= [UIImage imageNamed:NAVIGATION_SETTINGS];   
UIButton *rightBarButton = [UIButton buttonWithType: UIButtonTypeCustom];
[rightBarButton setBackgroundImage: settingsButtonImage forState:UIControlStateNormal];  
[rightBarButton addTarget: view action:@selector(settingsButton:) forControlEvents:UIControlEventTouchUpInside];
rightBarButton.frame = CGRectMake(0, 0, 50, 40);  
view.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: rightBarButton];

UIImage *logoutButtonImage= [UIImage imageNamed:LOGOUT];
UIButton *leftBarButton = [UIButton buttonWithType: UIButtonTypeCustom];
[leftBarButton setBackgroundImage: logoutButtonImage forState:UIControlStateNormal];  
[leftBarButton addTarget: view action:@selector(logout:) forControlEvents:UIControlEventTouchUpInside];
leftBarButton.frame = CGRectMake(0, 0, 65, 32);  
view.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: leftBarButton];


}
.

hanno provato a chiamarlo sia in viewdidload e viewwillappear, ma in vana.

Ecco come lo chiamo in ViewController.

- (void)viewDidLoad
{

[super viewDidLoad];

//other setups here.

[Utility setNavigationBarContents:self]; 

}
.

È stato utile?

Soluzione

Ho ottenuto la soluzione aggiungendo Questo codice nel mio appDelegate.m

// added so that navigation bar background image works in version lower than 5.0

@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
UIImage *img = [UIImage imageNamed:NAVIGATION_BAR_IMAGE];
[img drawInRect:rect];
}
@end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top