0

I am using QLPreviewController for showing the pdf. And I am sending pdf by tapping the share button and then tap on email in the QLPreviewController.

But i don't know how to get that share button method in QLPreviewController to validate that the email account is available or not. Here is the screenshot:

enter image description here Please let me know about this.

Thanks in advance.

Rashad
  • 11,057
  • 4
  • 45
  • 73
Sarabjit Singh
  • 1,814
  • 1
  • 17
  • 28

2 Answers2

0

if you have UInavigationController then you can add a bar button for sharing the content. Or you can add a share button in your viewcontroler.

Use MessageUI. Add the delegates MFMessageComposeViewControllerDelegate, MFMailComposeViewControllerDelegate.

- (IBAction)contactBtn:(id)sender {
    if ([MFMailComposeViewController canSendMail]){
        MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
        [controller setSubject:@"Subject"];
        [controller setMessageBody:@" " isHTML:NO];
        [controller setToRecipients:[NSArray arrayWithObjects:@"a@wa.com",nil]];
        controller.mailComposeDelegate = self;
        [self presentViewController:controller animated:YES completion:NULL];
    }
    else{
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Failed!" message:@"Mail can not be sent. Check your email settings." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil] ;
        [alert show];
    }
}

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [self dismissViewControllerAnimated:YES completion:NULL];
}
Rashad
  • 11,057
  • 4
  • 45
  • 73
  • @Rashad.....i am using QLPreviewController and when QLPreviewController open there is some options for sharing pdf or file...and when i tap on mail button it will open the Mail composer...but i am not able to detect the button actions of sharing..So i am not able to add the above method...SO please let me know where i put this method in QLPreviewController – Sarabjit Singh Apr 21 '14 at 05:38
  • Where is your sharing button? in navigation bar? – Rashad Apr 21 '14 at 05:39
  • It is in the QLPreviewController and i am not able to detect this sharing button method.... – Sarabjit Singh Apr 21 '14 at 05:40
  • Can you share a screenshot? – Rashad Apr 21 '14 at 05:40
  • Can you tell me how to share screenshot here...? – Sarabjit Singh Apr 21 '14 at 05:43
  • Select edit in your question. Then you can find a button squre in green color. – Rashad Apr 21 '14 at 05:45
0

The QL previewer is working on separate process. Something like a different app. So there is no way to customize the share button. see details here

This may help you. See this answer.

Community
  • 1
  • 1
QCG
  • 2,569
  • 3
  • 20
  • 25