Last active
January 28, 2016 14:17
-
-
Save Krumelur/a10bd857060b99fb6e08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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