I have QLPreviewController, but I use PresentModalViewController()to show QLPreviewControllerdirectly. For reasons not related to the explanation, I would like to have my own UIViewController, which will create my own view, and in this view I would like to use QLPreviewController. It should be easy, I thought, but the code below just doesn't do anything. QLPreviewControllers is ViewDidAppearnever called. (In my example below, the PreviewController inherits from QLPreviewControllerand encapsulates the delegate, preview element, and source). Can someone explain what is wrong with the code below (except that it is pointless :-))? Oh yes: in my test case, I present the controller below modally. It is displayed, but without preview.
public class OuterPreviewController : UIViewController
{
public OuterPreviewController (QLPreviewControllerDataSource oDataSource) : base()
{
this.oDataSource = oDataSource;
}
private PreviewController oPreviewController;
private QLPreviewControllerDataSource oDataSource;
public override void LoadView ()
{
this.View = new UIView();
this.View.Frame = new RectangleF(0, 0, 500, 500);
this.View.BackgroundColor = UIColor.Red;
}
public override void ViewDidAppear (bool animated)
{
base.ViewDidAppear (animated);
this.oPreviewController = new PreviewController();
this.oPreviewController.DataSource = this.oDataSource;
this.View.AddSubview(this.oPreviewController.View);
this.oPreviewController.View.Frame = this.View.Frame;
this.oPreviewController.View.Center = this.View.Center;
}
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
return true;
}
}
source
share