Мой код здесь:
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];
}
Приведенный выше код работает правильно для iPhone, но не работает в iPad.