UIDocumentInteractionController not working in iPad Real Device for iOS Objective c

96 views Asked by At

My code is here:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        NSLog(@"Downloading Started");

        NSURL  *url = [NSURL URLWithString:urlToDownload];
        NSData *urlData = [NSData dataWithContentsOfURL:url];
        if ( urlData )
        {
            NSArray       *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString  *documentsDirectory = [paths objectAtIndex:0];

            NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,strFileName];

            //saving is done on main thread
            dispatch_async(dispatch_get_main_queue(), ^{
                [urlData writeToFile:filePath atomically:YES];
                NSLog(@"File Saved !");

                [self openDocumentIn:filePath];

            });
        }

    });


- (void)openDocumentIn:(NSString*)path {
    [self dismissViewControllerAnimated:YES completion:nil];

        controller = [[UIDocumentInteractionController alloc] init];
        controller.URL = [NSURL fileURLWithPath:path];
        controller.delegate = self;
        controller.UTI = @"com.adobe.pdf";

        [controller presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];
}

The above code is working properly for iPhone, but it does not working in iPad.

0

There are 0 answers