Large text not displaying as multiple lines for UILabel in a custom tableview cell - swift

Setting up the UILabel on the attributes inspector as follow expands the cell and display the large text as multiple lines correctly for a Subtitle tableview cell:
Lines = 0
Line Break = Word wrap
But this doesn't work in a custom tableview cell for some reasons. In the custom cell, I added new labels and setup the attributes the same way but the cell doesn't expand.

It could be a matter of constraint.
Check to see if there are any conflicting constraints or fixed settings.
In order for elements of a cell to be set flexibly, the height of the cell must be set to the automatic value.
When I set it up like this, I was able to get the results I wanted.

Related

Override tableView.separatorStyle for a single cell or section

I'm trying to set the tableView.separatorStyle to UITableViewCellSeparatorStyleNone for a single section (or row, I suppose), but allow it to be set to the default for every other section.
As an example (of the unintended behavior):
While the rows at the bottom (and top) of the image should display the default gray line surrounding each section, for this particular section, even though I have set the backgroundColor of the cell to [UIColor clearColor], I would also like to remove the separator from this particular section.
There don't seem to be any delegate/datasource methods that allow overriding this on a per-section basis. The documentation for the separatorStyle property mentions:
UITableView uses this property to set the separator style on the cell returned from the delegate in tableView:cellForRowAtIndexPath:.
So it sounds like it's applied after I've built my cell, and the setter is only at the UITableView level, it is not visible at the ..Cell level.
the separatorStyle property can't be used for a specific cell. It will be used for all the cells. If you want to add separators just for some cells, add a UIView inside the cell's vie that will act as a separator and set the separatorStyle to UITableViewCellSeparatorStyleNone.
In cellForRow.. you can check the cell that will be provided to the table view and decide if the separator should be visible or not.
Just set a custom separator inset of 1000 for cells that you don't want to have separators.

Set UITableviewcell frame when tableview editing enable

I am showing data in tableview and on editing it will be as in image. (i had allowed editing only for rows those were come after 4 th index).
Now i want to first four image cell frame as in the below reference image.
And i last i need the output as in the below reference image
.
If any suggestion or references for this problem.
Thanks
For the first four cells, set a transparent image to cell.imageView.image This is not the perfect answer by any means but this will do the trick you want.
OR
For the four cells you can set the cell.textLabel.text by adding few spaces upfront like,
cell.textLabel.text = #" YOUR TEXT";
Your question is not clear.
I think you need the text alignment of all cells in same manner. If it is the case, I'll suggest three options:
When editing is pressed reload the tableView and add necessary spaces for first 3 rows
If you are using custom cells make another one for first three cells with exact spaces
If you are adding UILabel as subview of these cells change the frame
You can create the following by creating two sections in the UITableView , where for the second view you can set the editing TRUE (not in first section) . Also pass the title for second section as "On My Pad" as shown in your reference image .
Hope it will help you !

Plain style tableview: can we display only the required number of rows?

I have a normal UITableView with its style as plain. I am facing UI issues regarding of it.
If I have only one entry it will show more than one row. One row can be displayed with group style of table but in this option I can't make it as editable.
To avoid these extra cells you can set the tables footer view
tableView.tableFooterView = [[[UIView alloc] init] autorelease];
I hope this is what you wanted.
In the plain style, section headers and footers float above the content if the part of a complete section is visible.In plain style it tableView shows number of rows to fit the tableSize with its empty rows.You can make the visible rows to the count you wanted by using CustomCells instead of default cell of the tableView.
Refer http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html

do I need separate UILabel in a custom UIView to have separate UILabel lines in a UITableViewCell?

do I need separate UILabel in a custom UIView to have separate UILabel lines in a UITableViewCell?
That is, if I want to have a TableViewCell that has all text, but the text needs to contain 4 separate rows for 4 separate strings (e.g. Name, Title, Description, Location), and each these separate rows could include a wrap around.
To ask the question the other way around, is there way with a normal UITableViewCell using it content view and single text label, to force Carriage Return/New Line points at the end of each of the four strings? Oh yes, and the cell height will need to be calculated for each Cell as it may vary (just in case this is significant)
The answer to the last question: NO. (Answer to the title: YES.)
You can build a cell in its own NIB file. An exercise I suggest if you've never done it.
Layout the size/location/resize functionality as you like it.
your table view controller can be the owner of the file,
add an outlet to the TV controller of loadedCell, and call load nib
every time you want to alloc a new cell,
i suggest tagging each of the cell labels, and accessing them
that way, and setting the loadedCell value to nil after loading it,
p.s. a UILabel often wraps text undesirably, or is hard to layout in a cell to look good, consider the other values of lineBreakMode for your labels
p.p.s. it will employ a text shortening behavior depending on adjustsFontSizeToFitWidth and minimumFontSize (taking this and lineBreakMode into consideration)

UItableview returns more row?

i have done like
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
tableview is in UITableViewStylePlain.but it shows correctly 3 data on 3 tableview cell.but after that there is empty tableview cells ...but when i declared UITableViewStyleGrouped, it shows only 3 tableview cells... perfectly...what i have to do disappear empty tableview cell
in UITableViewStylePlain..any help pls?
Your table contains 3 table cells and those cells beneath it are not empty table cells. The row seperators are just drawn based on the previous row height giving the impression that there are more cells than you actually specified.
You could set the separatorStyle of the table view to UITableViewCellSeparatorStyleNone, either in code or in Interface Builder. But doing so disables the seperators all together, so you would have to draw some kind of separator yourself in your cells if you still wanted a grafical separation between the actual cells.
Another option would be to set the color of the separator to the color of the background of the table.
I myself would not worry about this if you're application has a standard table look, as it's default behaviour & users should be used to seeing that. Altough I must admit that I have set the separatorStyle to none in a previous project, because the table had a look that deviated from the standard table look. I did have to draw a fine separator line at the bottom in the table cell.