更改MFMailComposeViewController中的导航栏标题



我似乎无法更改导航栏上的标题,导航栏被设置为电子邮件的主题(在本例中为"我的主题")。在这种情况下,我想去掉标题,要么使用空字符串作为标题,要么使标题不可见。

MFMailComposeViewController *mfViewController = [[MFMailComposeViewController alloc] init];
mfViewController.mailComposeDelegate = self;       
[mfViewController setSubject:[NSString stringWithFormat:@"My Subject"]];
[mfViewController setMessageBody:[self emailBody] isHTML:NO];
[mfViewController setTitle:@""];

其中,您展示了ModalViewController

[self presentModalViewController:controller animated:YES]; // Existing line

添加

[[[[controller viewControllers] lastObject] navigationItem] setTitle:@"Set the title"];

我相信这是iOS4带来的某种保护。

这里明确指出,您不得更改苹果提供的界面。

http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html

重要提示:邮件合成界面本身是不可自定义的,应用程序不能修改它。此外,在显示界面后,您的应用程序不允许对电子邮件内容进行进一步更改。用户仍然可以使用界面编辑内容,但程序更改被忽略。因此,在显示界面之前,必须设置内容字段的值。

我搜索过论坛,有些人的应用程序被拒绝了,所以我想你应该克制自己不要这么做。

希望能有所帮助。快乐编码:)

最新更新