0

I have some problems with NSRect : everything works great for my image until I open Full Screen. My image moves down accordingly NSRect positions and not of image's constraints. How can I fixe my constraints for this ImageView in NSRect?

let imgImage1 = NSImageView(frame: NSRect(x: 375, y: 430, width: 105, height: 79))

[1]: https://i.stack.imgur.com/

J.A.
  • 61
  • 1
  • 5
  • 1
    Anytime you add hardcoded values in your constraints, you will face issues when the size of the container view changes. In your case the values width = 105, height = 79 are what is giving you the problem. When working with autolayout, try to position the views based on certain "rules", rather than fixed values. – TheAppMentor May 17 '17 at 11:15
  • You don't think that I can add something like minx.., miny.. etc? Because it concerns my gif that I cannot display in other way.. Without constraints it works not properly too.. I mean in Full Screen. So I add the constraints and all of images looks great except of gif. May be I don't need fix the x and y at all for it in NSRect? – J.A. May 17 '17 at 11:37
  • 1
    You could create an outlet from constraint to the related view controller. In the view controller, you can watch for screen size changes and update your constraints to a value appropriate to the new screen size. – TheAppMentor May 17 '17 at 11:39
  • I don't know how do it but your mention about constraints help me to decide placing my box in other position in order to see my image approximatively correct. But I don't understand why it is me who depend on view and not view depends on me) It must be the way to do it programmatically because I've noticed that GIF doesn't show up without NSRect and NSRect fixe my image for all that doesn't work correctly when you change the view size (constraints doesn't work, only NSRect data). I see the code read itself , ok, but I would like to know how I can do it myself.. In any way, Thanks – J.A. May 17 '17 at 12:41

0 Answers0