0

I recently submited an app and it got rejected due to the isse:

the share button does not function, when a user presses it no action occurs

It was working before I submit it to appstore. But now it's not.

I am unable to present the document interaction controller.

HEre is what I had working before:

 UIAlertAction* share = [UIAlertAction
                             actionWithTitle:@"Share"
                             style:UIAlertActionStyleDefault
                             handler:^(UIAlertAction * action)
                             {
                                 [self shareImage];
                                 [alert dismissViewControllerAnimated:YES completion:nil];

                             }];

After executing this I got the warning:

_bsmacherror (os/kern) invalid capability (20)
_bsmacherror (os/kern) invalid name (15)

then I put the shareImage code on main thread:

     dispatch_async(dispatch_get_main_queue(), ^{
                  [self shareImage];
     });

The warning is disappeared......But it still doesnt open the document interac controller

And the code to open doc interac controller is:

-(void)shareImage{

    UIButton *button = (UIButton *)nil;
    NSURL *URL = [NSURL fileURLWithPath:_savedImagePath];

    if (URL) {
        // Initialize Document Interaction Controller
        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];

        // Configure Document Interaction Controller
        [self.documentInteractionController setDelegate:self];

        // Present Open In Menu
        [self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES];
    }

}

I set the UIDocumentInteractionControllerDelegate and I checked that image exists at the _savedImagePath .

Is there any error handling method for doc interac controller ?

How do I solve the issue ?

Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
  • Why do you set this line `UIButton *button = (UIButton *)nil;` ? It makes no sense to use a nil button's frame as rect. – Nicolas S Nov 13 '15 at 15:07

1 Answers1

2

Your problem appears to be due to button being nil and trying to present the controller from the nil button's frame. That gives you a frame of CGRectZero. Why are you doing that?

Show the controller from a valid frame or from a UIBarButtonItem.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Exactly, that was my comment on the question. It could use the frame of the sender of the IBAction if there was one, in this case a button so `[sender frame]`. – Nicolas S Nov 13 '15 at 15:10
  • but bar button item doesnt have frame property right ? In my app I have two bar buttons, but I need to have frame set to open the doc interaction controller!!! – Teja Nandamuri Nov 13 '15 at 15:11
  • @Mr.T Please look at the documentation for `UIDocumentInteractionController`. There is a method to present from a bar button item. – rmaddy Nov 13 '15 at 15:12
  • https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentInteractionController_class/#//apple_ref/occ/instm/UIDocumentInteractionController/presentOpenInMenuFromBarButtonItem:animated: – Nicolas S Nov 13 '15 at 15:13
  • it worked. I have no idea, why it worked previously though i pass the button as nill!!! – Teja Nandamuri Nov 13 '15 at 15:17