In Interface Builder I have a simple view that contains a UIImageView and am trying to constrain the image view's width and height. I have added constraints several ways but whenever I run in the Simulator the image view does not display correctly but always adopts the dimensions of the PNG image, whose dimensions are smaller than the simulator's device. The Content Mode for the image view is Scale to Fill. I am loading the xib like this:
VCMain *vc = [[VCMain alloc] initWithNibName:@"Main" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];
navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
navControllermodalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:navController animated:YES completion:nil];
I have tried constraining the image view to the superview, and constraining it to the Safe Area, but nothing changes. Regardless of which I choose console printing reveals that the Safe Area always takes on the dimensions of the image view (which oddly takes on the dimensions of the png file, even though the setting is Scale to Fill).
I also tested assigning an image larger than the Simulator's dimensions (using iPhone Xs btw) and smaller. You can see in the pics below that the image view does not conform to the constraints.
What am I doing wrong? And why is the Safe Area conforming rather to the image size? Below are pics of IB that show settings, and then pics showing how the Simulator renders things.
When I use an image smaller than the Simulator device dimensions I get this:
and though you can't see, the Safe Area dimensions are {{0, 0}, {320, 480}}, exactly the size of the PNG.
When I use a version of the image much larger than the Simulator device's dims I get:
and again the Safe Area dimensions are exactly the size of the PNG, in this case {{0, 0}, {2133, 2789}}, even though the main view there has dims of {{0, 0}, {375, 812}}