Xamarin.iOS iOS 8 UITableView custom cell height does not change - uitableview

I am trying to create a UITableCell that grows based on their content like this recipe.
I have added all required parts as per recipe but I don't know what went wrong. Here is My Code.
My custom table cell height is not changing and it remaining at the default height.
FYI: Min iOS support 8.0.

In order for the table to grow you need to have a chain of autolayout constraints from top to bottom.
You are missing the constraint that links the top label with the bottom label:
If you add that it will then look like so:
Seeing as you uploaded the code, Here is your code with the updated constraint

Related

AutoLayout to dynamically size UILabel Height and Width in Map callout?

I have to populate data on 2 UILabels located in .xib. This is used for Google Map SDK iOS for a custom callout (in map annotation). How do I set constraints in interface builder using Auto-layout ?
Here is what I have for now. I need to make height and width dynamic. Thus some callout does not include arrow icon.
How each label attributes looks like:
Its almost there, what happening is container view doesn't expand/shrink according to description label.
What are the steps I should follow to build this view from scratch (for the learning purpose as well) ? Plus different ways this can be achieved?
Just change number of lines to "0" for label, auto layout will handle rest of the things. Remove height constraint because the height of the label will be determined by font size and number of lines of text.
.

Swift dynamic table text goes outside cell width

i just created a uitable view with dynamic cells, and as you can see with the insets, the cells have a correct width. But as shown on the image, the label goes out of the screen. I've set truncate tail, fixed font size... I can't manage to get this text truncated.
Should i do it programatically when creating the cell.text.value?
Help is very much appreciated here.
You might not have set frame in LayoutSubviews(). Initially when tableviewcell loads it always gives same width value but when layoutSubviews gets called it gives correct frame.
If you have done it in storyboard then you might have given hardcoded value.
Use Custom TableViewCell's
You can design the way you want and also you can set label/title width height font etc easily .
Make sure you register your tableview cell in viewdidload() or else it will crash
Here are two stack views, each with the same content - the text of the top label is this is a really long label that will extend past the right edge
The top one does not have a Trailing constraint.
The bottom one does have a Trailing constraint of 8.
That really looks like the issue you are running into.
Solved the issue. Initially i had dropped a table view inside the view controller and set the prototype cell to 1 in IBinspector. For an unknown reason, the constraints were not working. Ended up setting protoype cells to 0 and dropping a new table view cell from the object library.
That did the trick.

iOS multiline label not gong to multi-line in Xcode 7.3

I'm trying to set this up and have always done this in code and would like to get this done in modern version of Xcode 7.3.
I do the following steps:
drag out a UILabel
set the number of lines to 0
set Line Breaks to Word Wrap
But this isn't breaking and representing all the data. The data is being populated though. What else do I need to do?
edit 2
added border for this
The problem is that when you do this in code, your label is not using auto layout. But when you drag into the storyboard, your label is using auto layout, so the rules are different. You need to add constraints.
What you do now depends on what you want. First you'll need constraints for top and left of the label. Then, if you add constraints for just width, the label will grow downwards as it fills with text. If you add constraints for both height and width, the label will simply fill up within that size.

Layout changing when running the app

I've been trying for days to make one layout of my app to work well, and after days of learning and mistakes I still can't get the table cell layout to look how I want it to be.
This is how my cell .xib looks like in the editor:
http://i.stack.imgur.com/VEr3r.png
And this is how my app looks like when running with suggested constraints:
http://i.stack.imgur.com/wiK1f.png
Why is that? How I can find my mistake and make the layout like it supposed to be, in the view?
Suggested constraints are rarely what I actually wanted to see.
For each label with fixed text, lock the horizontal and vertical positions either to the view or to the next adjacent item.
For imageViews, choose the size you want and lock the height and width.
For labels that you will be dynamically changing the text on, pick a size that will hold the longest string and lock the width. You'll need a vertical position constraint.
You have many options to simplify your layout.
you can use the stakview or create a static UITableView and insert your component inside the cells and enter the Constraint. excellent tutorial http://www.runtimecrash.com/2015/09/17/exploring-uistackview/

TableViewCell with multiple columns

I have an application in which I want to have a tableView with custom tableViewCell that has five columns.
I want them to be like 20%, 30%, 15%, 20% and 15% of the whole cell's width, because I want my application to launch on iPhone and iPad.
What is the best way to do this?
Now I have created a tableViewCell prototype with 5 labels. I also added constraints to them but the width constraint is just a constant. Also when I added width constraints to labels, some collisions appeared there and I don't know how to fix them.
Here is a screenshot.
You can create table view cell with collection view. By that, you can get different part in cell as well as you can change each column width programmatically based on your needs.
Thanks
A table view has only one column and allows vertical scrolling only. link
If you want to use a few columns, you can use UICollectionViewController
I also added constraints to them but the width constraint is just a constant. Also when I added width constraints to labels, some collisions appeared there and I don't know how to fix them
To fix it change width constraints to be a multiplier of superview width.

Resources