6

I'm trying to make a sharing app extension to handle URLs from Safari. The XCode project template provides a ViewController that is a subclass of SLComposeServiceViewController. My problem is that my extension is not going to fit into the "standard" sharing template - I need to provide a custom UI for it. So I changed the parent class to the normal UIViewController. My extension continues to load fine in Safari - but I can't figure out how to size the UI similar to the SLComposeServiceViewController.

My ViewController is initing with full width x height of the device and even after I call [self setPreferredContentSize:CGSizeMake(320.0f, 320.0f)]; which is recommended if AutoLayout is not used, as a test to see if the size is reduced, nothing happens.

I've tried this in both the simulator and on my iPad with iOS 8 beta 5.

Dhiraj Gupta
  • 9,704
  • 8
  • 49
  • 54

1 Answers1

0

I was able to change the size of my share dialog by doing...

let frame = self.view.frame
let newSize:CGSize = CGSize(width:frame.size.width, height:frame.size.height * 2)
self.preferredContentSize = newSize

It animated and everything.

  • 2
    What method did you put this in? I've tried `viewDidAppear`, `viewWillAppear`, `viewDidLoad`, to no avail – lionello Jan 23 '18 at 03:37