Skip to content

Instantly share code, notes, and snippets.

@Krumelur
Last active January 28, 2016 14:17
Show Gist options
  • Save Krumelur/a10bd857060b99fb6e08 to your computer and use it in GitHub Desktop.
Save Krumelur/a10bd857060b99fb6e08 to your computer and use it in GitHub Desktop.
using System;
using UIKit;
using QuickLook;
using Foundation;
namespace Preview
{
class PreviewDataSource : QLPreviewControllerDataSource
{
#region implemented abstract members of QLPreviewControllerDataSource
public override IQLPreviewItem GetPreviewItem (QLPreviewController controller, nint index)
{
return new QLItem ("Some Image", NSUrl.FromFilename ("icon.png"));
}
public override nint PreviewItemCount (QLPreviewController controller)
{
return 1;
}
#endregion
}
class QLItem : QLPreviewItem
{
public QLItem (string title, NSUrl uri)
{
this.title = title;
url = uri;
}
private readonly string title;
public override string ItemTitle
{
get { return title; }
}
private readonly NSUrl url;
public override NSUrl ItemUrl
{
get { return url; }
}
}
public partial class ViewController : UIViewController
{
public ViewController (IntPtr handle) : base (handle)
{
}
QLPreviewController preview;
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
preview = new QLPreviewController ();
preview.DataSource = new PreviewDataSource ();
this.View.AddSubview (preview.View);
//this.PresentViewController (preview, false, null);
}
public override void DidReceiveMemoryWarning ()
{
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment