After exploring this problem, asking the same question in another forum and using different code examples, I cannot get this code to work using the UIDocumentInteractionController in C #. However, I can get it to work with the objective-c tutorial related in the above question. This is not useful since I need code in C # instead of objective-c.
Stack Overflow, QLPreviewController.
Monotouch - QLPreviewController
, . PDF, , .
, , PDF , "".
:
QLPreviewController previewController= new QLPreviewController();
previewController.DataSource=new MyQLPreviewControllerDataSource();
this.PresentViewController(previewController,true, null);
:
public class MyQLPreviewControllerDataSource : QLPreviewControllerDataSource {
public override int PreviewItemCount (QLPreviewController controller) {
return 1;
}
public override QLPreviewItem GetPreviewItem (QLPreviewController controller, int index)
{
string fileName = @"example.pdf";
var documents = NSBundle.MainBundle.BundlePath;
var library = Path.Combine (documents,fileName);
NSUrl url = NSUrl.FromFilename (library);
return new QlItem ("Title", url);
}
}
QlItem:
public class QlItem : QLPreviewItem
{
string title;
NSUrl uri;
public QlItem(string title, NSUrl uri)
{
this.title = title;
this.uri = uri;
}
public override string ItemTitle {
get { return title; }
}
public override NSUrl ItemUrl {
get { return uri; }
}
}