What may I have done wrong so that my ScrollView is not shown correctly in Simulator?
The Storyboard shows everything fine. The ScrollView is also scrollable.
Scroll View Screenshot
The simulator shows you what you get based on your "Auto-layout" constraints.
Looks like you have a lot of "hard-coded" distances which will not work well in different screen sizes.
Your scroll view is squeezed between 300 & 390 points which results in less space for "lastgames" image, so it gets scaled.
Try to play with Xcode's preview settings to see various screen sizes.
In storyboard you can stretch the uiviews bounds which may not be the true dimensions because of your constraints. When that happens a little yellow arrow pops up (which is also visible in your screenshot). Try clicking this button to restore the bounds to you specified constraints (screenshot attached). try this
Related
I'm working on a project where I want the following in an NSTableViewCell:
Image
Text
Subtitle text
The NSTableView is in a window which the user can expand or contract. When the window expands and contracts, the text wraps as needed.
That much is working.
When it comes to the image view, I can't get the thing to resize at all. I don't understand how the text automatically wraps, but images don't automatically scale. I've been working on iOS so long that I might have missed something in how stack views differ between iOS and macOS, but I never had this problem in iOS.
I don't have much code because the text wraps properly without any code at all, so instead I posted a minimal project showing the problem on Github:
NSImageTableViewTest
Some things I tried:
I have to set the width/height of the image view, or the text won't wrap. It seems to me that the reason why is that if I keep the image view unbound, the table view starts at the width of the image.
I tried setting the leading and bottom constraints of the image view to no avail.
I tried setting the constraints of the NSStackView, but that doesn't help constrain the frame of the image view.
Question: do I have to change the frame of the image view in code? I did try that, to no avail.
At this point, I'm stumped and I'm sure the fix is something easy that I overlooked.
Thanks.
The image view doesn't shrink because the default Content Compression Resistance Priority is too high. Set the Content Compression Resistance Priority to (a bit lower than) "Low (250)".
Here's what happened: I had a pretty much finalised app. I added a feature, which is completely unrelated to the GUI (so I think), I noticed a strange behaviour of GUI elements which have already been polished and worked flawlessly. After two weeks of playing around, disabling/enabling code, recreating and altering stuff I'm out of clues on how to solve this.
Take a look at this picture:
There are two bugs which appeared simultaneously and that's why I combine them into one question.
I have a simple background view with .wantsLayer = true and .masksToBounds = true. On it I have multiple views with the same settings and a .cornerRadius to their layer. A few weeks ago this worked perfectly. Now I can see some (! not every) corner not actually being cut off but displaying (often simply black) content.
Some corners show white content (top left). Some display the content of a completely different layer (the bottom views)!
To clarify: for debugging reasons I added a simple red layered view below the white one at the top of the picture. I expect the white view to have rounded corners (red!) both at the top and and bottom. However the top one is white (with a red line) and the bottom one isn't round at all. Second, and this one is weird to me, the bottom views do not have anything set to the colour red at all! The red coloured corners come from the colour of the top view's layer! If I make the top view's background view blue instead of red, the corners of the bottom views become blue as well.
What I found out so far:
The corner thing normally happens when the parent view is not set to .maskToBounds = true. It is set in my example and also it worked before. How could I have messed this up without touching any related code or views in Interface Builder?
I failed to find anything online regarding layers showing content of other layers in portions which should not be visible...
Any help would be highly appreciated!
Note: there's a drop shadow on the bottom views which is a completely different view underneath doing nothing but dropping a shadow. I forgot to remove it for the screenshot.
I don't know the reason behind this behaviour but I found a solution.
One of the many views (with CALayers) and subviews is a NSProgressIndicator. And I assigned a Content Filter named "Hue Adjust" with the value of -0.5 to it, in order to have a different colour of the bar. Removing this Content Filter in Interface Builder solved the problem and the GUI looks again like it should:
I would still be interested to know why this happens and how I can keep my tinted progress bar without losing the corners...
I'm trying to set a constrain of "0" to a UIImageView from the sides (left & right) but when I add the constrain with "Constrain to margin" checked, it pins the image all the way to the edge of the ViewController while it should keep some distance, why is this happening?
I was having the same problem and recently resolved the issue by turning off the safe area. Safe Area Layout is enabled by default. To disable Safe Area Layout in Xcode 9, choose View > Utilities > Show File Inspector and deselect the checkbox for Use Safe Area Layout Guides. This should correct the issue. Good luck, hope it helps.
Check to see if your UIImageView is overlapping or placed past that margin line. If this is the case, the constrain to margin thing doesn't do anything. What I did to fix this was manually move that object so that it was away from the margin line and try again.
This lets you keep the Safe Area.
I found that if the UIView is overlapped with or by another view this issue also happens - for example if you want to put an image up by the side and you also have a full screen camera preview.
The solution for me was to drag the view where I wanted it (i.e. to one side) and then set the constraints and it behaved properly from then on - I did not have to remove the safe view. This is with Xcode 10.1.
I've just begun playing around with XCode and currently reading on Objective-C!
I have made a dark background and a book-ish "background" on top of it. Example here.
But how do I set it in a constant position on every iOS device and every iPhone screen-sizes?
From the looks of your image I assume that you want it to be fixed to the bottom.
To do that place your image view in the bottom of its superview and change the autosizing to be fixed to the bottom like in this image below.
The little red box in the view labeled "example" shows you how the image view will behave when the superview is resized.
If you want your image view to have a constant position anywhere else, just position it where you want it and set the appropriate autosizing for it (once again, look at the red box to see how it will behave when resized).
If the right pane is not visible press the right pane button in the tool bar (image below) or use the keyboard shortcut ⌘+⎇+0 to display the right pane or ⌘+⎇+5 to go directly to the size inspector.
I am just playing with an iPhone test app that orients the view when the simulator is rotated left or right. Everything worked fine when my view had a white background, however when I altered the view background to a darker color I noticed a white edge (1 pixel) around the view as it rotates. Has anyone come across this before or know how I might get rid of it. Indeed it might be an issue with the simulator that won't show on the actual device, but I just thought it worth asking for future reference.
gary
I have seen something similar before..
Go through the nib (.xib) files and make sure that all of the views have an appropriate dark background colour set, most notably the nib file which contains the "window". Click on them and set the background colour.
I've never noticed it but then again I've never tried to rotate a very dark view. There might be a small border to keep the view from visually bleeding into the status bars or other views.
Rotation and scaling in the discrete domain( as against analog) is quite difficult, because after a rotation/scaling the rotated location may not be a pixel location. You can suppress the effect by smoothening the edges, but I believe that is not implemented, and so the bug.