作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 UIDocumentinteractioncontroller 在 ibook 等其他应用程序上打开 pdf。
但是很难找到关于它的文档。
现在我可以展示开放部分。但是当我点击 ibooks 的图标时。什么都没发生。
我是否需要在委托(delegate)中做一些事情,例如 documentInteractionController:willBeginSendingToApplication:???
最佳答案
首先你必须在你的 .h 文件中添加 UIDocumentInteractionControllerDelegate
即:
@interface MyDocumentViewController : UIViewController <UIDocumentInteractionControllerDelegate>
在您的 .m 文件中添加协议(protocol),这使您能够了解发生了什么......
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application{
NSLog(@"Send to App %@ ...", application);
}
- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application{
NSLog(@"Finished sending to app %@ ...", application);
}
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller{
NSLog(@"Bye");
}
当然,您必须将 UIDocumentInteractionController 的委托(delegate)设置为该模块。我是这样解决的:
-(BOOL)canOpenDocumentWithURL:(NSURL*)url inView:(UIView*)view {
BOOL canOpen = NO;
UIDocumentInteractionController* tmpDocController = [UIDocumentInteractionController
interactionControllerWithURL:url];
if (tmpDocController)
{
tmpDocController.delegate = self;
canOpen = [tmpDocController presentOpenInMenuFromRect:CGRectZero
inView:self.view animated:NO];
[tmpDocController dismissMenuAnimated:NO];
}
return canOpen;
}
关于objective-c - 如何在 ibooks 等其他应用程序上打开 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8643714/
我是一名优秀的程序员,十分优秀!