2010-12-16 5 views
1

in meinem AppDelegate habe ich dies:Problem navigationbar und UIImagePickerController

@implementation UINavigationBar (CustomImage) 
- (void)drawRect:(CGRect)rect 
{ 
UIImage *image = [UIImage imageNamed: @"HeaderViewBG.png"]; 
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; 
} 
@end 

für Set Hintergrundbild für navigationbar. Aber ich brauche eine UIImagePickerController zu verwenden, also habe ich diesen Code:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (buttonIndex == 1) { 
     UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
     picker.delegate = self; 
     picker.allowsEditing = YES; 
    picker.navigationBar.barStyle = UIBarStyleDefault; 
     picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     [self presentModalViewController:picker animated:YES]; 
     [picker release]; 
    } 
} 

Das Ergebnis ist:

alt text

Ich möchte den Standard UIImagePickerController navigationbar Stil. Ich möchte nicht, dass der Bildhintergrund in der Anwendung verwendet wird, ich möchte die Standardnavigationsleiste.

Wie kann ich es beheben?

Vielen Dank.

+0

Haben Sie dieses Problem gelöst? – CVertex

+0

gut, oder? Ich bin auch neugierig zu wissen. –

Antwort

0

entfernen Sie den Code für die Navigationsleiste und entfernen Sie die Anweisung, wo Sie drawRect diese Funktion aufrufen.

Entfernen Sie die benutzerdefinierte Navigationsleiste und dann erhalten Sie die Standard-Navigationsleiste.

0
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { 
    if ([navigationController isKindOfClass:[UIImagePickerController class]]) { 
     if ([[UIDevice currentDevice] systemVersion].floatValue >= 8.0) { 
      [viewController.navigationController.navigationBar setBarTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"navbar1"]]]; 
     } else { 
      [viewController.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar2"] forBarMetrics:UIBarMetricsDefault]; 
     } 
    viewController.navigationController.navigationBar.tintColor = [UIColor whiteColor]; 
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; 
    titleLabel.textColor = [UIColor whiteColor]; 
    titleLabel.textAlignment = NSTextAlignmentCenter; 
    titleLabel.font = [UIFont boldSystemFontOfSize:18.0f]; 
    titleLabel.text = @"photos"; 
    [viewController.navigationItem setTitleView:titleLabel]; 
    viewController.edgesForExtendedLayout = UIRectEdgeNone; 
    } 
}