Marco Almeida
Marco Almeida

Reputation: 1303

Can't resize UIViewController using custom segue and Storyboard

I have a custom tabBar app using custom segue with a problem on the size of the destinationViewController always loading in fullscreen and not at the size I defined in the attributes Inspector.

I set the Size of the ViewController as Freeform in the Simulated Metrics and at Simulated Size ate the Size Inspector I defined the width as 1024 and height as 693. I also unchecked the Resize View from NIB even though I am not using .xib files.

I have tested the project on both Simulator and real device, but does not work.

When I click the button it shows the destinationViewController but it hides the TabBar, which of course should not happen.

The pictures shows better what I am facing:

Attributes Inspector

Size Inspector

First ViewController

Segued ViewController

Upvotes: 1

Views: 552

Answers (1)

Marco Almeida
Marco Almeida

Reputation: 1303

Finally managed to find a solution. The problem was actually with the perform() function which I was using this way:

override func perform() {
    var src = self.sourceViewController as UIViewController
    var dst = self.destinationViewController as UIViewController

    src.presentViewController(dst, animated: false, completion: nil)
}

And the fix is that I changed the presentViewController line with this one:

override func perform() {
    var src = self.sourceViewController as UIViewController
    var dst = self.destinationViewController as UIViewController

    src.view .addSubview(dst.view)
}

Now everything works fine!!!

Upvotes: 1

Related Questions