I create a UIActivityViewController, where I transmit images and texts to Facebook, email, 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 a 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];
Then I tried to show the mail composer from my root controller (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 I am getting is the following:
Mail messaging timeout to determine CanSendMail status
Talaa source share