4

I am creating a UIActivityViewController where I am passing images & texts to Facebook,mail,twitter.

-(void)Activityshowmethod{
NSLog(@"The Selected Photo Count %i",[self.selectedPhotos count]);
//UIActivityViewController *activityViewController2 =[[UIActivityViewController alloc]init];
NSMutableArray *newArray=[[NSMutableArray alloc]init];
NSMutableArray *newArraytext=[[NSMutableArray alloc]init];
logactivity *shopactivity=[[logactivity alloc]init];

[shopactivity setSelectedthings:self.selectedPhotos];
for (log * ChosenPhot in self.selectedPhotos) {

    NSString *initalTextString = [NSString
                                  stringWithFormat:@"I am Sending from my log : %@",
                                  ChosenPhot.categoryname];
    //[newArraytext arrayByAddingObject:initalTextString];
    [newArraytext addObject:initalTextString];
    CreateShoplogTagImage *createimagetag=[[CreateShoplogTagImage alloc]init];
    UIImage *newimage=[createimagetag Imagetag:ChosenPhot];

    [newArray addObject:newimage];

}
//NSMutableArray *addArray=[[NSMutableArray alloc]initWithObjects:newArray,newArraytext, nil];
NSMutableArray *addArray=[[NSMutableArray alloc]initWithArray:newArray];
[addArray addObjectsFromArray:newArraytext];
UIActivityViewController *activityViewController2 =[[UIActivityViewController alloc]initWithActivityItems:addArray applicationActivities:@[shopactivity]];

[self presentViewController:activityViewController2 animated:YES completion:^{}];

}

Although I would like to share files in the same UIActivityViewController , so I created my own UIActivity, I created the File inside it in

 - (void)performActivity
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"slog.log"];
    NSLog(@"The String of the Path is :%@",filePath);
    NSData *savedData = [NSKeyedArchiver archivedDataWithRootObject:self.Selectedthings];
    [savedData writeToFile:filePath atomically:YES];
    //[self.Selectedthings writeToFile:filePath atomically:YES];
    TestViewController *test=[[TestViewController alloc]init];
    NSLog(@"I have Pushed the Shoplog Button");
    [test showmailcomposer:savedData];
}

Then I tried to show the mail composer from my rootviewcontroller ( Testviewcontroller) With the Following Code :

    -(void)showmailcomposer:(NSData*)datafile{

    if ([MFMailComposeViewController canSendMail]) {
       MFMailComposeViewController *mailer =[[MFMailComposeViewController alloc] init];
        mailer.mailComposeDelegate = self;
        [mailer setSubject:@"Check out these Shoplog Photos"];
        NSMutableString *emailBody = [NSMutableString string];
        [mailer addAttachmentData:datafile mimeType:@"log" fileName:@"Slog"];

        [emailBody appendFormat:@"Sent from my log " ];
        [mailer setMessageBody:emailBody isHTML:NO];
        [self presentViewController:mailer animated:YES completion:^{}];
    }
}

The error that I am getting is the following :

timeout messaging Mail to determine CanSendMail state

4

0 回答 0