AutoLayout issue with an iPad - ios

I am using a TableView with the UIImageView and UILabel on the Table Cell. I set constraints for UIImageView as like this:
And for the UILabel, I set constraints like this:
All the constraints set are working properly on every iPhone model as I want but it's not working as expected on iPad. There is a gap on the right portion of the cell. I want the UILabel to be filled completely with the margin of 8 on the right side.
How to fix this issue? Am I doing the wrong way? Any suggestion?
Thanks. :)

Seems like you are using wAny hAny size class. The constraints added for image view and label looks fine. Check the table view constraints if you dragged table view in View Controller. Or else you can try giving aspect ratio to label, maybe this solves your problem.

Related

Tableview ContentView Cell label constraints displaying incorrectly

Currently I'm displaying two labels and view on a tableview contentview cell on my app. Without constraints, the labels display correctly on the device. However, when I add constraints to the labels in the storyboard, they always align to the left. I'm currently using top, bottom, leading/trailing (left & right), and have in other attempts also set height and width.
New Constraints storyboard:
However, when I run it on any device, it always looks like this:
Actual view:
I'm wondering why this keeps happening. I want to avoid doing constraints programmatically in this app to show I can use storyboard, but this one problem has stumped me. I've tried reading up as much as I can, but I just can't get it to work. Any idea how to get it to look like the first picture, all the time when, adding constraints?

Size Class compact height doesn't work properly with UIStackView's axis and real device

This is how it looks like in my storyboard and Preview:
And this is what I set up in storyboard for that UIStackView:
But everything changes when I run this on real device:
Why it happens like that?
Please note that I have here two UIStackViews: icon with labels box, two buttons. The second one works correctly, but not the first one. Why? it is done exactly the same way. Two direct subviews of UIStackView
EDIT
I realised that problem arise ONLY with UIImageView as direct subview of UIStackView.
Just tap the "+" button disribution section and choose Any x Compact height and fill equally. I hope this works well.

Objects in Xcode Storyboard disappearing

I was designing a storyboard in Xcode. Then I wrote a bit of code. When I came back, all my objects in a view had disappeared. Everything's working I just can't see them on my storyboard. But they appear when I run it. I really need to add a uiimageview to this view. But since there are no objects visible I can't. Any help appreciated and
I think this would be the case with you.
Suppose you add label in controller when size class is any other than wAny hAny. Suppose you are adding label in wCompact hRegular size class.An adding constraint for it.
Now you move to other size class. Suppose you change it to wAny hAny.
Now it looks will not find on storyboard and look like this.
In 4th image label looks like hidden and also not visible on storyboard.
So it is better to design storyboard in wAny hAny to make it visible in all size classes. Assuming this will be the case with you.
Did you add constraints to your views?If yes,you changed the size of top level view,just select views and CMD+Option+=(this is resizing view as suggested). If no,add constraints first. If you drag view with blue lines,this will sometimes work,not always.
Select a size class compact in width like "wCompact hAny"
See the width of size class in red box.

Dynamicaly view with different content

I have got UIView with UIImageView + UILabels + UITextView.
I don't know how to make this views in UIScrollView, that will show corectly on horizontal and portrait?
Any sugestion?
I thought about uitableview with many cells as UIImageView and Labels, but I need use uiTextView.textContainer.exclusionPaths For image and text.
Any sugestions or solutions?
Tableview might be a better solution or just simply try to use autoLayout with the elements you want. Working in scrollview with autoLayout might be tricky on some occasions but these seem good solutions to me.
define the size and position of contentView inside scroll view
even if you set all constraint from your contentView to scroll view (top, right, bottom, left) to some constant values, the size of your contentView is not defined!!! that is very common mistake ...
set height and width of the contentView, that is all (without any relation to scroll view). like width = 5000, height = 5000. why not? the scroll view will be just like a small window to big room behind. it is the only reason why to use a scroll view, isn't it?
Please visit below link:
http://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/
Hope it will help solving your issue.

iOS Autolayout constants issues which cause the UIView not occupy the whole width in iPad

Here is the screenshot of my ViewController in my Storyboard. As you see, there is a UITableView inside.
And the autolayout setting is like this:
There is only one setting for "wAny hAny". That means the layout should be the same in iPhone and iPad. Unfortunately it's not. It's fine in iPhone. But in iPad, the result is like this:
The tableview is not taking the whole width of the UIView. Why? Can anybody suggest? Thanks
Uncheck constrain to margins, and set all constraint values zero.

Resources