Keep Graphical Outline when Screen Size Changes - iphone

Beginner...
I suppose somewhat related to the question below, I would like the view controller to appear the same on each device with only the size of the graphics changed, (storyboard iPhone 8 vs iPhone 4s)
I've tried my best to read about and understand the Constraints, but with no luck. I add a constraint, then click away from the "Add New Constraints", and when I select the object again to view constraints it appears as if nothing is set anymore, (Constraints added & Constraints gone)
Even if they are sill there, but this isn't how you see them, the image still moves when I check the storyboards or the simulators of two different sized devices.
Any recommendations on how to fix either issue or just somewhere else to look for answers would be well received!
I would like to automatically align all the graphics I've placed in the "View Controller", (Unaligned Storyboard),
and have those graphics resize themselves to maintain their placement when loaded onto a device with a different size screen, (Main Storyboard of two devices)
I've decided I want most of the graphics to only be in the center of the controller.
EDIT
this has been solved
I've discovered how to align the graphics as I desire by clicking the Align "Horizontally in Container"
I'm not sure how or why I didn't see this sooner.
Unfortunately, the graphics still become distorted when on a different sized screen.

I've discovered how to align the graphics as I desire by clicking the Align "Horizontally in Container"
I'm not sure how or why I didn't see this sooner.
Unfortunately, the graphics still become distorted when on a different sized screen.

Related

Unity, at higher resolution (2560 x 1440) tester cannot click the navigation elements on the screen even though they are in position

Here is my issue, the way my game works is that you click on the edges of the screen to navigate. This is done through an Overlay Canvas using OnPointerClick. I colored the navigation areas, and scale the canvas according to screen size and the navigation areas appear on their screen as they should. Yet they CANNOT click any of the elements for some reason. They have another monitor that works without issue. They've noted that their larger monitor is AMD. I've also confirmed that the ability to navigate in game has not been hindered. I have never had this issue (or any other testers) on 1920x1080 monitors.
I have completely exhausted what the issue can be, they cannot even navigate on a bare bones tutorial. Any ideas would be GREATLY appreciated.
Here is an image of their screen and the respective clickable navigation areas.
[img]https://i.imgur.com/NVQkA8g.png[/img]
Unity 2019.2.14f1
Put a Image component without sprite, because without that, you will not detect any click. You can set the alpha to 0 after you see that working.
Also check the anchors of the navigation areas.

Auto Layout Swift 4 Xcode 9 For Multiple Devices - Am I doing it Wrong?

I am having severe difficulties finding a clear working world example of auto layout on multiple screen sizes. Most tutorials have basic stuff like a button thats centralised and then after adding constraints in Interface Builder it scales with the device. One button is simple but in my example for the iPhone 4:
There are quite a lot of labels / buttons and some that are not central. The above screen shot is exactly how I want it to look on all devices.
The app is for portrait only but I want to target all devices. I tried slowly adding constraints to items from the bottom up using a multiple of the superview to position and size items and then applying aspect ratio to UI Objects (got as far as the got it button but not the red arrow buttons) but as you can see in the next picture for the iPhone 8 plus... the white space isn't going to perfectly fill like in the iPhone 4 which will leave me with a big gap at the top.
Is there a way I can change just the iPhone 8 plus layout in Interface Builder to build a layout that caters for the extra screen size?
The iPhone 8, SE and X layouts are equally awkward with extra white space.
I tried size classes but that changes it for all phones.
Is there a way to centre what I have done so far?
How do you guys position objects in auto layout that are not centred?
Am I going about it the wrong way by applying X / Y constraints using a multiple of the superview? - same for the width. I'm only specifying widths as a multiple of the superviews width then adding aspect ratio.
I just need a real world working example I can learn the basics from or a system to create for multiple devices that I can follow. I don't want to use a 3rd party library.
I really hope someone can help point me in the right direction!
Krivvenz.

Xcode constraints and uiimageview as a background

I am sorry if I am going off topic, this is not a question about code, but I am having troubles with constraints
In my app I use a UIImageView as background, I set the constraint for the image to fit the screen and it works
But after that i have a lot of labels and buttons,and if i add even one constraint to one of these elements,it disappears or goes out of the UIImage
I want to set the UIImageView as background,so all the other elements can be placed on the image using constraints ,how do i do it?
To simplify the process can i group all of my interface elements in some views and then apply the constraints to the view?
I need a good explanation and/or tutorial about this elements, at the moment my interface on iPhone 4 fits ok until the iAd shows up, and on the other iPhones there is a lot of empty space
take a look at this tutorial. Hopefully, it will works.
http://www.raywenderlich.com/83276/beginning-adaptive-layout-tutorial
Try this: with one of you elements, cmd+click (or right-click) on it and drag upward until the background UIImage is highlighted. Release and select 'left'. This sets a pinning constraint to the left side of the background image.
Then cmd+click and drag to the side, and select 'top'. This should pin your element to an intelligible spot; it may still need some sizing help, but at least you will be able to guess where it will show up.

Constraints issue in Xcode

I'm having some issues with the constraints in my app. Here is how it looks on the iPhone 4 (that's how i want it to look, and how i usually setup my interface, is this the proper approach or not?)
Now, when i switch to the iPhone 5 screen it looks like this
and as you can see, the blue dots (which is UIButtons) are not placed where i want them to be. I made my constraints rely solely on the right side of the view (since that is the one re-sizing, i found that in order for you'r views to align themselves accordingly, it doesn't help to align them to the left side). I don't really know how to fix this. I am finding this new iPhone screen to be a real pain in the arse. Any good advice on how to work with this new screen without a lot of headache would be appreciated :)
Thanks on advance
It looks to me like the are still the same distance from the right side of your view, as you said you set them to be, while the background has stretched to fit the new size. I suspect it's actually the background that isn't doing what you want it to do (keep the same aspect ratio and show more stuff on the left), or try keeping the buttons relating to left and right to stay aligned with the stretched background image.

iOS playing cards

I currently have an image which has every suit and value of a deck of playing cards in it. There is an UIImageView to show this picture, with width and height set to show just one card at a time and view mode set to "top left" so it doesn't stretch.
Now I'm just showing what happens to be the top left card, the ace of clubs. I tried finding a way to offset the view to show a different portion of the UIImage, but couldn't find a suitable property (tried fiddling with "frame" and "bounds").
Is there a way to get such an offset working, or am I going about this the wrong way? I'd like to keep all the cards in one image in "sprite sheet" style so that they would be easy to modify later instead of having a bunch of separate pics.
Set the bounds to what you'd like to show, enable 'clipToBounds' and make sure the content stretch mode is set properly. That should work.
EDIT: I do recommend making different images though, because of memory issues (even though not the whole image is shown, you still fully have it in memory).