html文件用safari打开方式,在html中打开(在Safari中)
嗯,你說的是UIDocumentInteractionController那么。
實施UIDocumentInteractionControllerDelegate在UIViewController
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller { return self; }
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller { return self.view; }
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller { return self.view.frame; }
然后添加一個按鈕,導航欄,彈出選項對話框:
// example: opening a .html file
NSString *index = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
// self.controller is a UIDocumentInteractionController ivar
self.controller = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileToOpen]];
self.controller.delegate = self;
CGRect rect = self.navigationController.navigationBar.frame;
rect.size = CGSizeMake(1500.0f, 40.0f); // move the box right down under the button
[self.controller presentOptionsMenuFromRect:rect inView:self.view animated:YES];
支持特定文件應出現在應用程序的列表。如果您沒有注冊您的應用程序以支持某種類型的文檔,您仍然可以選擇“QuickLook”選項。所有這些都發生在與文件交互的任何應用程序上(因為文件本身并未在UI上公開)。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的html文件用safari打开方式,在html中打开(在Safari中)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php二进制加密_怎样给PHP源代码加密
- 下一篇: amr 转mp3 java_JAVA 音