我正在使用QuickLook
来预览图像,PDF和Microsoft Office文档。预览文档可以很好地工作,但是每当我尝试打开文档的链接时,其ShouldOpenUrl
委托方法都不会触发。以下是我尝试过的代码。
我在具有iOS v11的iPhone和iPad上测试了我的应用程序。
// Open documents using title and file url
public void OpenDocument(string title, string url)
{
var rootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
var previewViewController = new QLPreviewController();
previewViewController.DataSource = new DocumentPreviewDataSource(title, url);
previewViewController.Delegate = new PreviewControllerDelegate();
rootViewController.PresentViewController(previewViewController, true, null);
}
// QLPreviewControllerDelegate Implementation
public class PreviewControllerDelegate : QLPreviewControllerDelegate
{
public override bool ShouldOpenUrl(QLPreviewController controller, NSUrl url, IQLPreviewItem item)
{
Console.WriteLine("PreviewControllerDelegate::ShouldOpenUrl: {0}", url.AbsoluteString);
return true;
}
}
答案 0 :(得分:0)
您可以使用swapcase
s='ABCD'
print(s.swapcase())
在OpenDocument方法中
abcd
并覆盖
weakdelegate
和public partial class xxxViewController : UIViewController,IQLPreviewControllerDelegate,IQLPreviewControllerDataSource //. . .
中的方法
public void OpenDocument()
{
var previewViewController = new QLPreviewController();
previewViewController.View.Frame = View.Bounds;
previewViewController.WeakDelegate = this;
previewViewController.WeakDataSource = this;
this.PresentViewController(previewViewController, true,null);
}
我使用上面的代码,它工作正常。