#pragmamarkActions-(IBAction)previewDocument:(id)sender{NSURL*URL=[[NSBundlemainBundle]URLForResource:@"sample"withExtension:@"pdf"];if(URL){//InitializeDocumentInteractionControllerself.documentInteractionController=[UIDocumentInteractionControllerinteractionControllerWithURL:URL];//ConfigureDocumentInteractionController[self.documentInteractionControllersetDelegate:self];//PreviewPDF[self.documentInteractionControllerpresentPreviewAnimated:YES];}}-(IBAction)openDocument:(id)sender{UIButton*button=(UIButton*)sender;NSURL*URL=[[NSBundlemainBundle]URLForResource:@"test"withExtension:@"pdf"];if(URL){//InitializeDocumentInteractionControllerself.documentInteractionController=[UIDocumentInteractionControllerinteractionControllerWithURL:URL];//ConfigureDocumentInteractionController[self.documentInteractionControllersetDelegate:self];//PresentOpenInMenu[self.documentInteractionControllerpresentOpenInMenuFromRect:[buttonframe]inView:self.viewanimated:YES];}}#pragmamark-#pragmamarkDocumentInteractionControllerDelegateMethods-(UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController*)controller{returnself;}