i have created a Storyboard where i create universal views for all iphones in portrait form. Simple views work just great, but as soon as you add different views and sub element something goes wrong. Can someone give me some tips what i am doing wrong?
I will be thankful for every kind of tips/advises how to get rid of this annoying view...
Have a nice sunday!
I found out the solution, the problem is that you can set all the measures in percent. But for to count all the sizes, XCode needs minimum 1 measure for width & height. If it gets the size of single element in your design, it can calculate all other sizes.
Related
I'm working on an app where I've got a design with two similar layouts for horizontal/vertical. And it's on an iPad. I've found other answers but I can't use most of them because I've got two tableviews in my view, which means I can't use xibs. I'm also making it for the iPad so changing layout based on height/width variation doesn't work.
The design I'm trying to achieve is in the pictures below. What I'm having troubles with is moving the two views that are stacked on the right in landscape mode to be next to each other and short in vertial. Also I need to move those four buttons and the right-side table to being below the other two views.
I've tried overriding trait functions as described in this blog post but for the life of me can not get it to work.
I'm looking for any advice anyone could give me. I feel like I've hit a wall and can not figure out how I can implement this.
just give the height and width constraints of the subviews with respect to the superview in ratio it'll work.
I am asking perhaps one of the easiest questions lol but just could not figure it out.
I have some view controllers created based on the screen size of iPhone 7, but when I change devices to iPhone 7plus and iPhoneSE, my labels and buttons were all misplaced...
I have uploaded what they look like in different devices, can somebody please help?
WhatItLooksLikeOniPhone7
WhatItLooksLikeOniPhoneSE
To keep the UI elements at a defined place you need to something that will keep the elements at their position. And hence you need to use autolayout.
Autolayout is basically a constraint based system which will layout the ui elements.
There are many tutorials available.
Using Xcode 7.2 [using swift but that shouldn't matter for this] ... I have put two buttons, 'Done' and 'Add', into a UIStackView as such:
But at runtime the 'Add' button is always smaller as:
I have tried every combination of fill and spacing on the StackView, etc. I have tried setting widths and heights but the 'Add' button is always smaller. I have the same problem in another UIStackView (also horizontal) where the Add button is first.
The two buttons shown have the same natural pixel size and are multi-sized. For example here is the setting for 'Add':
I tried deleting it from Xcode and adding it back. Is there some factor that I am missing? This is driving me nuts.
One hint that might help is that I think that when I first added it with this name, it actually was smaller, but since then I have deleted it and re-included it in the project. Perhaps there is some 'memory' there that I can't find?
Ack, thanks so much for the answers and comments. But the problem was that the '#2x' Add image was misscaled. Fixing that fixed the problem; only took me days to find it as I guess I checked and rechecked the 1x and 3x sizes but never the 2x one. Sorry to waste your collective time.
I am still not very comfortable with all the layout settings and have 6 storyboards in the app that have around 60 layout warnings, but am getting there.
I am starting a new project which should be working on every iOS device size possible.
The project is rather simple. The main view will be a scroll view and it will hold a '+' button (where it says 'button' in the image) in the top right corner. (It does not really matter, I'm just trying to give the general idea of what I'm trying to understand and implement.)
A small example:
What is the right approach for this kind of problem?
Should I create a different storyboard for each device?
Should I start creating an adjustable scroll view that will hold the needed buttons with some constraints (if at all possible)?
I have read this tutorial:
auto layout
which explains the auto layout nicely, but does not mention the issue I'm trying to figure out.
Any thoughts?
Use AutoLayout and position your views relative to one another (so no x pixels spacing between views). Make only one storyboard for all devices, when a different view should be loaded on another device (like a completely different layout), select the appropriate size class and adapt the views and constraints.
Then it will be recalculated on every device.
The storyboard has a preview section where you can choose a device to simulate the view on.
I am trying to lay out objects on a Storyboard using the interface builder yet when I run the app on an iPad2, the layout is being messed up and objects are not appearing where they should. All the objects are there but they are being moved horizontally and not the same number of pixels! For instance, I have two ImageViews overlayed on one another (one is 100x100 and one is 75x75 centred within) but when the app is run on the iPad, they are both being moved horizontally across the screen by different distances!
I'd like to add screenshots but unfortunately I can't for privacy reasons.
I know it's vague but does anyone have any ideas on where to start looking to fix this?
Thanks.
I had this problem too when I was first making an iPad app.
Try fiddling with some of the 'struts & springs' of the interface elements in the storyboard. To do this, select some of the interface elements, then on the right panel go to the size inspector and try some things with the 'Autosizing' rectangle.
Hope it helps!