English 中文(简体)
• 如何把邮件功能称作根基观察台?
原标题:How can i call a mail function in Root ViewController?
  • 时间:2012-04-23 10:26:41
  •  标签:
  • iphone
  • ios

我想寄出一个附有附件的邮件。 我的附录一为邮件职能设立了一个单独的班级,而根基的话,我有顿在。 Email It。 当点击时,必须叫我的信功能,但只字不提。

  MFMailViewController *controller = [[MFMailViewController alloc] initWithNibName:"MFMailViewController" bundle:nil];                


[[self navigationController] pushViewController:viewController animated:YES];
[viewController release];

在此之后,我知道,我必须使用邮件功能。 没有人能够帮助我发现这一点。

最佳回答
问题回答

Create an instance method in MFMailViewController class with some parameter like dictionary or NSArray

when you click on Email it button you are creating object of MFMailViewController then called the instance method using the controller object and pass the parameter or info to. then push it s view to navigation.

#import <Foundation/Foundation.h>

@interface MFmailViewController: NSObject

{}

- (撤销)sendEmail:NSMutableDictionary* withData;

@end
#import "MFMailViewController.h"

@implementation MFMailViewController

- (撤销)sendEmail:NSMutableDictionary* withData;
{
    //definition goes here.................

}
@end

MFMailViewController *controller = [[MFMailViewController alloc] initWithNibName:"MFMailViewController" bundle:nil];                

[controller sendEmail:withData];
[[self navigationController] pushViewController:viewController animated:YES];
[viewController release];

simple where you want to send mail just define this code in you method ..... but first define delegate in .h file of your viewController delegate is MFMailComposeViewControllerDelegate and then in button click method write this code......

       MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
        controller.mailComposeDelegate = self;
        [controller setToRecipients:@"Recipients Name"];
        [controller setSubject:@"your subject"];
        [controller setMessageBody:@"Your Text Here for Mail" isHTML:YES]; 
        if (controller)
        {
            [self presentModalViewController:controller animated:YES];
            [controller release];
        }

and then you can just paste bellow mailComposerDelegate method in yourViewController.m file.....

- (void)mailComposeController:(MFMailComposeViewController*)controller  
          didFinishWithResult:(MFMailComposeResult)result 
                        error:(NSError*)error;
{
    if (result == MFMailComposeResultSent) {
        NSLog(@"Mail Sent");
    }

    [self dismissModalViewControllerAnimated:YES];

}




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签