开发者

Changing the title of a MFMailComposeViewController

Although i know changing MFMailComposeViewController is fround upon, i'm taking a risk. I found some 开发者_如何学Goideas such as

[self presentModalViewController:controller animated:YES]; // Existing line
[[[[controller viewControllers] lastObject] navigationItem] setTitle:@"SomethingElse"];

and

[[[[(MFMailComposeViewController*)vc  navigationBar] items] objectAtIndex:0] setTitle:@" SomethingElse"];

but the odd thing is that the title is "SomethingElse" for like 2 seconds and after that it returns to the subject that is set. I've tried other solutions as well but the same output.

I am using SHK (ShareKit) to connect to social. Here is the code from showViewController :

if ([vc respondsToSelector:@selector(modalPresentationStyle)])
        vc.modalPresentationStyle = [SHK modalPresentationStyle];

    if ([vc respondsToSelector:@selector(modalTransitionStyle)])
        vc.modalTransitionStyle = [SHK modalTransitionStyle];

[topViewController presentModalViewController:vc animated:YES];

 [[[[(MFMailComposeViewController*)vc  navigationBar] items] objectAtIndex:0] setTitle:@" "];



[(UINavigationController *)vc navigationBar].barStyle = 
    [(UINavigationController *)vc toolbar].barStyle = [SHK barStyle];



    self.currentView = vc;


I believe this is some kind of protection came with iOS4.

It is clearly stated here that you MUST NOT change the interface provided by Apple.

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

Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.

I knew some people being rejected because of this. I just wanted to warn you about this.


You just need to set the mail subject. Means [MFMailComposeViewController setsubject:@"yourTitle"]. Then this will be shown as a titile .but if you do not write anything in MFMailComposeViewController subject then by default it can show "New Message".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜