标签: uidocumentinteraction

如何向UIDocumentInteractionController预览添加按钮

UIDocumentInteractionController用于文件预览:

interactionController = UIDocumentInteractionController.FromUrl(url);    
interactionController.Delegate = new UIDocumentInteractionControllerDelegateClass(this);    
InvokeOnMainThread(delegate{interactionController.PresentPreview(true);}
});
Run Code Online (Sandbox Code Playgroud)

如何在视图顶部添加自定义按钮以执行某些操作?

c# xamarin.ios uidocumentinteraction uidocument

5
推荐指数
0
解决办法
408
查看次数

如果有另一个支持该文件类型的应用程序,则UIDocumentInteractionController文件未附加到Mail

.stl在iOS上打开文件UIDocumentInteractionController.我看到以下选项:

在此输入图像描述

现在,如果我选择Mail,它会自动将.stl文件附加到电子邮件中.没关系.

但如果我安装了另一个支持.stl文件的应用程序(例如MeshLab),那么我看到以下内容:

在此输入图像描述

如果我再次选择邮件 - 它将不再将文件附加到电子邮件中.

为什么会这样(为什么文件没有附加到第二种情况下的电子邮件)?有没有办法改变这种行为?

PS我正在使用Xamarin.iOS,但在这种情况下认为不重要.

xamarin.ios ios uidocumentinteraction

5
推荐指数
1
解决办法
711
查看次数

如何在MPMediaPickerController中使用UIDocumentInteractionController

我实现了MPMediaPickerController

- (IBAction)pickSong:(id)sender {
    MPMediaPickerController *picker =
    [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];

    picker.delegate                     = self;
    picker.allowsPickingMultipleItems   = NO;
    picker.prompt                       = NSLocalizedString (@"Select any song from the list", @"Prompt to user to choose some songs to play");
    picker.showsCloudItems = YES;

    [self presentModalViewController: picker animated: YES];
}
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
{
    [self dismissModalViewControllerAnimated: YES];
    if (mediaItemCollection.count > 0) {
        MPMediaItem *mediaItem = [mediaItemCollection.items objectAtIndex:0];
        NSLog(@"%@ - %@, %@", [mediaItem valueForProperty:MPMediaItemPropertyTitle], [mediaItem valueForProperty:MPMediaItemPropertyArtist], [mediaItem valueForProperty:MPMediaItemPropertyAssetURL]);


        self.fileURL = …
Run Code Online (Sandbox Code Playgroud)

objective-c mpmediapickercontroller mpmediaitem uidocumentinteraction

5
推荐指数
1
解决办法
3530
查看次数

如何更改UIDocumentInteractionController完成按钮文本和背景颜色

如何更改完成按钮的背景颜色和文字颜色?有没有办法可以更改导航栏颜色和导航栏标题颜色和底栏颜色?附件截图供参考: 在此输入图像描述

iphone uinavigationcontroller ios uidocumentinteraction swift

5
推荐指数
1
解决办法
2701
查看次数

处理URL的iOS应用未在“在...中打开”菜单中显示(例如,在Safari中)

在iOS Safari中单击“共享”按钮时(通过工具栏或长按链接),我希望我的应用程序显示为“在...中打开”选项(例如,“在新闻中打开” ”),以便我的应用(这是另一种网络浏览器)可以打开Safari共享的任何内容http://https://URL。

我已经在苹果info.plist文件中注册了文档类型“ URL”(我相信这是正确的类型,如果此假设是错误的,请更正!),我CFBundleDocumentTypes可以从Apple的“注册应用程序支持的文件类型”文档中猜到,他们的技术问答以及与之相关的StackOverflow帖子1 2 3

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>appIcon320</string>
            <string>appIcon64</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>URL</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>   <!-- Note: I have also tried 'Viewer' -->
        <key>LSHandlerRank</key>
        <string>Owner</string>    <!-- Note: I have also tried 'Default' -->
        <key>LSItemContentTypes</key>
        <array>
            <string>public.url</string>
        </array>
    </dict>
</array>
Run Code Online (Sandbox Code Playgroud)

我也用以下代码编写了这个存根方法AppDelegate.swift(尽管我认为实际上与使我的应用程序显示为“打开方式...”选项的第一阶段的成功无关):

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {opening-in-app-getting-uiapplicationlaunchoptionsurlkey-from-launchoptions?rq=1
    print("Received URL: \(url); from …
Run Code Online (Sandbox Code Playgroud)

mobile-safari ios uidocumentinteraction launch-services

5
推荐指数
0
解决办法
447
查看次数

UIDocumentsInteractionController显示iBooks但不打开它

我的UIDocumentsInteractionController正在使用一个带有"iBooks"按钮的动作表,但是当我点击那个按钮时,它只是解散它并没有把我带到iBooks.这是我的代码:

NSString *filenamePath =[NSString stringWithFormat:@"temp.%@", [[file path] pathExtension]];

    NSString *docDir = [DataCenter getDocumentsDirectoryPath];

    NSString *fullPath = [docDir stringByAppendingPathComponent:filenamePath];

    NSURL *url = [NSURL fileURLWithPath:fullPath];
    UIDocumentInteractionController *c = [UIDocumentInteractionController interactionControllerWithURL:url];

    BOOL success = [c presentOpenInMenuFromBarButtonItem:buttonBack animated:YES];
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?谢谢

iphone cocoa-touch objective-c ios uidocumentinteraction

4
推荐指数
1
解决办法
2697
查看次数

有没有办法限制UIDocumentInteractionController中显示的应用程序?

我目前正在显示一个UIDocumentInteractionController,以便我的应用程序的用户可以在另一个应用程序中打开一个文件.控制器弹出并列出应用程序没有问题.但是,它还会显示Cloud应用程序,例如Dropbox(我假设它几乎与每个有效的文件类型相关联),这非常令人讨厌.无论如何,我可以指定控制器只显示我想要的应用程序?

objective-c uti ios uidocumentinteraction

4
推荐指数
1
解决办法
1224
查看次数

通过UIDocumentInteractionController打开文件

UIDocumentInteractionController用于在我的应用程序中打开文档.我使用下面的方法预览PDF文件: -

- (IBAction)previewDocument:(id)sender 
{
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"];

    // Initialize Document Interaction Controller
    self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];

    // Configure Document Interaction Controller
    [self.documentInteractionController setDelegate:self];

    // Preview PDF
    [self.documentInteractionController presentOptionsMenuFromRect:down.frame inView:self.view animated:YES];

}
Run Code Online (Sandbox Code Playgroud)

我已经读过,我们也可以通过其他应用程序读取应用程序中的文件UIDocumentInteractionController.

在我的应用程序中,如何使用其他应用程序读取文件UIDocumentInteractionController?这一切是如何发生的?

ios uidocumentinteraction

4
推荐指数
1
解决办法
9822
查看次数

iOS 8中动态生成的文件"Open In"失败

我使用此代码将一些PDF数据保存到文件中,使用"打开方式"菜单将其发送到另一个应用程序,然后在完成后删除该文件:

- (void)openIn:(NSData *)fileData {
    // save the PDF data to a temporary file
    NSString *fileName = [NSString stringWithFormat:@"%@.pdf", self.name];
    NSString *filePath = [NSString stringWithFormat:@"%@/Documents/%@", NSHomeDirectory(), fileName];
    BOOL result = [fileData writeToFile:filePath atomically:TRUE];
    if (result) {
        NSURL *URL = [NSURL fileURLWithPath:filePath];
        UIDocumentInteractionController *controller = [[UIDocumentInteractionController interactionControllerWithURL:URL] retain];
        controller.delegate = self;
        [controller presentOpenInMenuFromBarButtonItem:self.openInButton animated:TRUE];
    }
}

- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller {
    // when the document interaction controller finishes, delete the temporary file
    NSString *fileName = [NSString stringWithFormat:@"%@.pdf", self.name];
    NSString *filePath = [NSString …
Run Code Online (Sandbox Code Playgroud)

filesystems nsdata ios uidocumentinteraction

4
推荐指数
1
解决办法
1206
查看次数

UIDocumentInteractionController无法在iOS 11中打开其他应用程序

我的应用程序将PDF分享给另一个第三方应用程序的能力在iOS 11中已经破坏.它显示了共享表,但是当我选择在另一个(第三方)应用程序中打开它时,它只是取消共享表并且什么都不做.

我已经确认的事情:

  • willBeginSending和didEndSending的委托方法都被调用
  • 打开第一方应用程序,如邮件或便笺工作正常
  • 文档选择器仍在内存中
  • 呈现预览工作正常,但预览内部的分享按钮仍然无法打开第三方应用程序
  • 我也试过用UIActivityViewController.共享URL会产生相同的行为.共享原始数据允许您"创建PDF",然后共享该PDF确实有效(但用户体验很糟糕).

有没有其他人经历过这个或有任何想法如何解决它?

以下是显示问题的示例应用程序的完整代码.我在一个新的"单一视图"应用程序中创建了它.故事板只有两个按钮连接到两个动作.

class ViewController: UIViewController {
    var docController: UIDocumentInteractionController!

    @IBAction func open(sender: UIButton) {
//        self.docController.presentPreview(animated: true)
        self.docController.presentOptionsMenu(from: sender.frame, in:self.view, animated:true)
    }

    @IBAction func check() {
        print(self.docController)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let url = Bundle.main.url(forResource: "OrderForm", withExtension: "pdf")!
        self.docController = UIDocumentInteractionController(url: url)
        self.docController.delegate = self
    }
}

extension ViewController: UIDocumentInteractionControllerDelegate {
    func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
        return self
    }

    func documentInteractionController(_ controller: UIDocumentInteractionController, willBeginSendingToApplication application: String?) …
Run Code Online (Sandbox Code Playgroud)

uikit ios uidocumentinteraction swift ios11

4
推荐指数
1
解决办法
1493
查看次数