0

I have an iPhone Plus which I'm using for development. I'm concerned that my app would be cramped or otherwise not have a good UI on 4-inch phones like the SE. Is there a way to simulate a 4-inch phone on the Plus? I imagine it would leave blank space at the top and sides of the screen.

The simulator doesn't work, since the scale is wrong. Everything appears bigger. It's also hard to test touch gestures on the simulator to see if they feel natural. Finally, it's a camera app, so it doesn't run on the simulator.

I'm fine with a third-party app or library to do this.

Kartick Vaddadi
  • 4,818
  • 6
  • 39
  • 55
  • Get a used 4-inch phone? I've actually borrowed a friend's phone in this situation. – matt Feb 21 '17 at 14:51
  • That's the obvious solution, but I wanted to check if there's another :) – Kartick Vaddadi Feb 21 '17 at 14:52
  • OK, but asking for "a third-party app or library" is against the Stack Overflow rules, and there isn't some magic built-in Apple way. The variety of iPhone screen sizes / hardware capabilities is a pain in the butt but there's no magic bullet for working around it. – matt Feb 21 '17 at 14:56

1 Answers1

0

You can easily simulate this using a container view controller:

class FourInchViewController: UIViewController {

  init(child: UIViewController) {
    self.child = child
    super.init(nibName: nil, bundle: nil)

    addChildViewController(child)
  }




  // Internals:

  private let child: UIViewController

  override func loadView() {
    let black = UIView()
    black.backgroundColor = .black
    view = black

    view.addSubview(child.view)
  }

  override func viewWillLayoutSubviews() {
    let size = view.bounds.size
    let w = CGFloat(320), h = CGFloat(568)
    child.view.frame = CGRect(
        x:(size.width - w)/2,
        y:size.height - h,
        width: w,
        height: h)
  }

  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
}

Then, in your app delegate, set this as your root view controller.

Kartick Vaddadi
  • 4,818
  • 6
  • 39
  • 55