tableview constraisnts in iphone 6 and 6 plus - swift

I am using a tbaleview and want to make sure they looks good in both the smaller and larger iPhones ( 6 and 6 plus), but even after setting all the constraints on the left right and top to 0, I still see this. Any thoughts ? Thanks.

It's probably because you accidentally set the width constraint to a constant. Delete the width constraint and it should work.

this tutorial helped me get it right. Had to set tableview to be horizontal in container and set the constraints mentioned in this video.
https://www.youtube.com/watch?v=ES69XgBDgeo&t=180s

it seems like might be you have given fix width constrain,
like this
Remove this kind of constrain if exist and done

Related

Xcode 12: TableView Cell image too big and covering text

I made some custom tableview cells and while everything else with them works, the images are really big and I cant get them any smaller.
I did this and its still flooding: I added height and width constraints and a 10 constraint to the left of the ImageView, and selected these settings
I can suggest a few things you can try to achieve it. I have illustrated 1 & 2 on the attached image:
Suggestion 1 is to make sure there is no ambiguity or constraint collision. It seems you have set two constraints for the width of your image. You might be setting it to be 'greater than' the width you want it to be.
Suggestion 2 is to also provide a constraint between the image view and your label view for the heading in order to prevent an overlap.
Suggestion 3 is to make sure that your imageView has a setting of "Clips to bounds' checked on the inspector.
Suggestion 4 Change your content mode to Aspect Fill instead of Aspect Fit
Suggestion 5 Complete your constraints, make sure everything is blue. I don't see top and leading constraint. This will help remove any ambiguity.
Suggestion 6 Use the view debugger, see what constraint values are being used, and the debugger will also show you hierarchies and view layers, which will give you more idea of what is going on.
Your imageView seems to have no x and y constraints. I suggest you to give top and leading constraints for the beggining. You should never see red lines to have stable layouts.

How to alter a specific constraint based on screen size of specific device?

I know I can change constraints programmatically and I know I can vary for traits.
Im working with two odd images in image views that I can't seem to line up perfectly in Ib using vary for traits. I only need to programmatically alter one constraint based on if the device is iPhone 6, 6plus, or anything else.
I thought I could do something like this in View did load:
this is giving me an error because I'm not setting up the sizing of the screen properly, I'm attempting to use the numerical point value size of an iPhone 6 in portrait.
if UIScreen.mainScreen.bounds.size == (CGSize: 414.width, 736.height) { //change Ib outtled constraint to x
}
am I on the right track? Is there an easier way to alter a single constraint by device?
Any advice is appreciated.
The correct way to do it is to check UIScreen, although I tend to use an inequality and a constant and to check width and height independently:
if UIScreen.mainScreen.bounds.size.width <= Constants.iPhone6Width {// change constraint constant here}
Remember that on iPad in multitasking mode you can end up with a narrow but tall screen, so you likely want to make any width constraint changes based solely on the width, whether or not you also have a smaller height. this is also why you want to use an inequality instead of checking for a specific screen size.

What is wrong with these auto layout constraints?

What I aim:
I want to have a table cell, in which every cell is horizontally divided in two halves. The upper half will contain 4 labels, and the lower half will contain 4 values which correspond to these labels.
Of these 4 items in every horizontal half, each of the last 3 items will occuppy 2/7 of total width, and the remaining 1 item will occupy the remaining of the total width, which is 1/7 of total width.
What I tried:
Putting a horizontal stack view in the content view of table cell.
Which will contain two vertical stack views
Where the upper vertical stack view will contain the labels and the lower vertical stack view will contain the values.
In short, I did this:
But I am getting these conflicts:
I really don't understand why I am getting these conflicts. I feel like I have provided enough constraints for auto layout to do the layout correctly.
Could you please tell me what is wrong here?
I'm on Xcode 8 and using iPhone 7 Plus as view, if that would make any difference.
This is a simpler case, and it isn't working as well:
Conflicts:
As you have provided the detail nobody can get understand and help to resolve your auto-layout issues, I suggest you to clear all constraints and try re-apply all the constraints again , give proper leading and trailing with x and y position the constraints will definitely works good,
Once you will try to apply twice or thrice you ll get know the exact problem and it will be get resolved quickly.
For auto-layout more practice needed to understand it briefly.
Hope it will help to you,
Thanks.

My Ag-grid display is getting messed up when I scroll

I have an ag-grid display with about 1000 rows and 3 columns ... initially the display looks fine ... but as I scroll, somewhere around the 150th column.. my grid display gets messed up .. I stop seeing the border, scroll bar, header of the grid and left and right columns disappear ... below is an image of what I see. if I scroll further down, I will stop seeing the left and right columns and the header completely..
Any help on this would be greatly appreciated.. I don't even know where to look.
(Note: please ignore the black lines in the left column. I had to cover the text before I can post the image here.)
thank you
Vij
I had the same problem, when i used Internet Explorer.
I'm not so sure, that in your case it is the same, but my problem was solved with the lagging.
When you initialize your ag-gird add this to it:
suppressScrollLag: true
I hope this solves your problem.
One other option, even though it's not the most elegant one, is to increase the number of rows that get rendered outside the viewable content:
gridOptions.rowBuffer = 100;
The default is set to 20 rows.

UILabel Text Not Wrapping

I am working on a Swift project with Storyboards where I want text to wrap in a label. In the old Objective-C version where I did not use a Storyboard I used the following settings and things worked perfectly.
Here are the settings for Swift
I have been reading about the potential auto layout issues with preferred width settings. I currently have them set to auto layout and the label itself is set to a width of 560. I've added a constraint to keep the label 20 pixels from the trailing superview and while I thought this would work I still cannot get the text to wrap. The dimension settings are below.
Can someone explain how to get the text to wrap?
First, the good news: You have set the label to 2 lines and Word Wrap. So it can wrap. Excellent.
Now you must make sure the label is tall enough. Either give it no height constraint, or give it a big enough height constraint that it can accommodate two lines.
Finally, you must limit its width. This is what causes the text to wrap. If you don't limit the label's width, it will just keep growing rightward, potentially continuing off the screen. The limit on the label's width stops this rightward growth and causes the text to wrap (and the label to grow downward instead).
You can limit width in several ways. You can have an actual width constraints. Or you can have a leading constraint and a trailing constraint, to something relatively immovable, such as the superview. And there is a third way: on the Size inspector (which you do also show, at the bottom right of your question), set the Preferred Width (it is shown at the top of the Size inspector): this is the width at which, all other things being equal, the label will stop growing to the right and wrap and grow down instead.
Declare your UILabel programmatically and give
yourUILabel.contentMode = .scaleToFill
yourUILabel.numberOfLines = 0
yourUILabel.leadingMargin(pixel: 10)
yourUILabel.trailingMargin(pixel: 10)
This worked for me.
Your text will wrap if you have provided lines number more than 1. However you may not be able to see it wrap if the label height is not enough to show the content. I suggest you to remove the height constraint or increase its value.
In case this helps anybody: I had followed the advice given here to fix my label not wrapping to two lines but nothing worked. What worked for me was I first deleted some of the relevant constraints in storyboard (I'm using auto layout) and saw that the label wrapped properly. I slowly added back the constraints I needed and everything still seems to work fine. So deleting and remaking your constraints may help.
What fixed this problem was changing the label type to "Placeholder" under Intrinsic Size in IB. When I changed this the text wrapped and the warnings went away.
As I see you interface builder. There are two problems. First one is with your constraints, and another one is with the property.
You gave it a fixed height which is wrong while line wrap. You need to make the auto-resizing label, i.e. remove height and add the bottom constraint or simple remove height depend on your situation. Your text is moving to the next line, but due to fixed constraint, you can't see it.
You enable the option to clip subviews which is wrong as it cuts your view and you are unable to view wrap word.
Add a new case:
DO NOT add constraints to your label with a TEXTVIEW, or the label will expand to right without limitation.
In my case i set my parent stackview alignment from center to fill and set UILabel to
label.textAlignment = NSTextAlignment.right