Question

I want to open PDF files using QLPreviewController in Monotouch, but I can't to do this.

QLPreviewItem is an abstract class, but object of this type returns method :

QLPreviewControllerDataSource.GetPreviewItem(QLPreviewController, int)

Anybody has worked example of QLPreviewController in Monotouch?

Was it helpful?

Solution

subclass QLPreviewItem, and then return object from GetPreviewItem:

public class QlItem : QLPreviewItem 
{ 
    string title; 
    Uri uri; 

    public QlItem (string title, Uri uri) 
    { 
            this.title = title; 
            this.uri = uri; 
    } 

    public override string ItemTitle { 
            get { return title; } 
    } 

    public override NSUrl ItemUrl { 
            get { return uri; } 
    } 
} 

OTHER TIPS

At least on Cocoa Touch, it is sufficient to return an NSURL object in the data source method (QLPreviewControllerDataSource.GetPreviewItem() on mono touch - previewController: previewItemAtIndex: on cocoa touch).

NSURL already implements QLPreviewItem. So unless you want to do fancy stuff, you don't need to subclass/implement QLPreviewItem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top