【问题标题】:iOS - remove UIImageView from MFMailComposeViewControlleriOS - 从 MFMailComposeViewController 中删除 UIImageView
【发布时间】:2012-11-30 14:18:35
【问题描述】:

我的 ViewController 有一个带有 Promt 的 navigationBar,在它之上我添加了一个自定义图像:

- (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 的导航栏在没有提示的情况下自动调整为普通导航栏,但我以前 VC 中的自定义图像不会消失。如何删除它并将标准黑色样式设置为我的导航栏?

【问题讨论】:

    标签: iphone objective-c ios cocoa-touch uinavigationcontroller


    【解决方案1】:

    您已使用 UIAppearance 代理设置了背景图片,该背景图片将影响应用中的每个导航栏。

    改变

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2010-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多