2012-11-30 36 views
0

ViewController有PROMT一個navigationBar,並在它上面我已經添加了自定義圖像刪除的UIImageView:iOS版 - 從MFMailComposeViewController

- (void)changeNavBar 
{ 
    UIImage *image = [UIImage imageNamed: @"logo_home.png"]; 
    imageView = [[UIImageView alloc] initWithImage:image]; 
    imageView.contentMode = UIViewContentModeLeft; 

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo_home.png"] forBarMetrics:UIBarMetricsDefault]; 

    imageView.frame = CGRectMake(0, 0, 320, 70); 

    [self.navigationController.navigationBar insertSubview:imageView atIndex:0]; 

    self.navigationController.navigationBar.backItem.backBarButtonItem.tintColor = [UIColor blackColor]; 
} 

但是,當用戶點擊「發送電子郵件」按鈕,創建MFMailComposeViewController和以模態方式呈現。

- (IBAction)emailPressed:(id)sender 
{ 
    NSString *emailTitle = event.title; 
    NSString *messageBody = [NSString stringWithFormat:@"%@ - %@", event.title, event.concertUrl.absoluteString]; 

    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; 

    mc.mailComposeDelegate = self; 
    NSLog(@"subviews: %d", mc.navigationBar.subviews.count); 

    [mc setSubject:emailTitle]; 
    [mc setMessageBody:messageBody isHTML:NO]; 

    // Present mail view controller on screen 
    [self presentModalViewController:mc animated:YES]; 
} 

MFMailComposeViewController的導航欄autoresizes正常的導航欄沒有提示,但以前的VC我的自定義圖像也不會消失。我怎樣才能刪除它,並將標準黑色風格設置爲我的導航欄?

回答

2

你已經使用UIAppearance代理來設置背景圖像,這將對應用中的每個導航欄產生影響。

變化

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo_home.png"] forBarMetrics:UIBarMetricsDefault]; 

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"logo_home.png"] forBarMetrics:UIBarMetricsDefault]; 
+0

工作!謝謝! :-) – Oleg

相關問題