1

カレンダー アプリケーションのコードによって追加されたイベントを、使用可能なメール アカウントに同期しようとしています。確認したかったのですが、ios5では可能ですか?? 私はそれを検索しようとしていますが、これに対する適切な解決策を見つけることができません。これについて考えている人はいますか??

もう 1 つ質問があります。それは、iPhone のカレンダー アプリケーションで新しいカレンダーを作成する ios5 の新しい機能を使用していることです。ローカル タイプのカレンダーを作成するたびに、それを作成できます。しかし、そのカレンダーがカレンダー リストに表示されません。なぜか隠れてしまう。これについて何か考えはありますか??

前もって感謝します

4

1 に答える 1

0

最初に MessageUI フレームワークをプロジェクトに追加し、これら 2 つをファイルにインポートします

#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

次に、xid でメールを参照するボタンを作成し、IBAction にリンクします (以下のように):

-(IBAction)emailSettings:(id)sender{

Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
    // check whether the current device is configured for sending emails
    if ([mailClass canSendMail])
    {
        [self displayComposerSheet];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"EMAIL" message:@"No Settings For Email" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
      }
    }

}

-(void)displayComposerSheet 
{
  MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];

    picker.mailComposeDelegate = self;
    [picker setSubject:@"StampedeBreakfast!"];

    // Set up recipients
    NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; 
    NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", nil]; 
    NSArray *bccRecipients = [NSArray arrayWithObject:@"third@example.com"]; 

    [picker setToRecipients:toRecipients];
    [picker setCcRecipients:ccRecipients];  
    [picker setBccRecipients:bccRecipients];

    // Fill out the email body text
    NSString *emailBody = [NSString stringWithFormat:@"Hey! This is my Email Body"];
    [picker setMessageBody:emailBody isHTML:NO];


    [self presentModalViewController:picker animated:YES];
 }

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   

switch (result)
{
    case MFMailComposeResultCancelled:
        NSLog( @"Result: canceled");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Result: saved");
        break;
    case MFMailComposeResultSent:
         NSLog(@"Result: sent");
        break;
    case MFMailComposeResultFailed:
        NSLog( @"Result: failed");
        break;
    default:
         NSLog(@"Result: not sent");
        break;
}

[self dismissModalViewControllerAnimated:YES];
}

これがあなたを助けることを願っています!!

于 2012-05-21T09:57:11.503 に答える