KLM
KLM

Reputation: 167

Xcode 'Deletes' Image View Inside Table View Based On Device Screen Size

I'm creating a simple app that includes a table view using Swift 5 and Xcode 11. Inside the table view(which, by the way, is fixed into landscape), there is a button on the right of the tableview cells and an image view with fixed constraints, size, and width on the left. Everything has been working out pretty well for my app, until I noticed that the image view would kind of 'disappear' if I changed the device to, for example, iPhone 5s, 4s, or even iPhone Pro(I'm testing with iPhone 11 Pro Max).

This is when the device is iPhone 11 Pro Max: 11 Pro Max

This is when the device is iPhone 11 Pro: 11 Pro

And here are my constraints for my image view: Constraints

Any help is appreciated
P.S. Ignore the image view that says 'img'

Upvotes: 1

Views: 60

Answers (2)

TheShy
TheShy

Reputation: 13

right Constraint should be negative,for example, img.snp.right = view.right - 20

Upvotes: 1

Harshal Bhavsar
Harshal Bhavsar

Reputation: 1673

After seeing both of the screen shots and the constraints I see what is the issue here.

It's the way you have applied the trailing constraint for the image which in your case is 663 (Should not be fixed). What you can try is Give width constraint to the image view and then change the trailing constraint something like below

Sample constaints

This should help you. Also what you have to take care of moving forward is the constraints you choose to apply coz that is the most important thing while desigining Responsive UI

Happy Coding.

Upvotes: 4

Related Questions