TableView automatic dimension - swift

I have set the auto dimension of the label but whenever data is loaded in table view it expand to 10 lines however text is about 1 line
enter image description here
Thats the code

Please check that picFlag is = "0" or not in response and make sure you have implemented estimatedHeightForRow delegate

Related

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 !

Space between labels when user leave a text field empty

Hi
I have some text field which, after a decoding, set some UILabel. The problem is that if the user leave some empty field , I don't like to see that space between the labels. I enclose a picture for a better understanding. thanks in advance.
instead of the view below use a uitableview with custom cells
Each custom cell having a label ...and add a cell if and only if u have a valid string in a textfeild..set userinteraction=NO and set some backgroung color to match ur view..
just put that string in the uilabel in the custom cell...thats it..

setting dynamic x coordinate of second lable in xcode objective c

i have a problem that i have two lables,
1) will contain a long text
2) this will be just More button (link)
so i want that when the first text ends then the second label starts right from where it end. but the problem is that the text is variable so i could not find any way to make it dynamic.
example
text of first row
"this is text of first label" "more"
text of second line
"test best" "more"
in the example the rows are of table view and two lables are separated by " so i want second label starting point from where the text in first lable ends
looking forward for some solution
Thanks & Regards!
NSString has some methods to calculate its size when displaying using given font (e.g. sizeWithFont: method) - you can use it to determine text width and place your more button accordingly (someZZZZ parameters must be available on runtime):
CGFloat firstLabelWidth = [firstLabel.text sizeWithFont:firstLabel.font].width;
CGFloat moreX = firstLabel.frame.origin.x + firstLabelWidth + someGap;
moreButton.frame = CGRectMake(moreX, moreY, someWidth, someHeight);
You may need to add some validation for cases when text in first label is too long to fit the screen etc, but in general this code should work.

value in the Table view is repeating after the 11th row

I am beginner iphone developer I want created table in programatically. In the table we take more than 20 row. But i have some problem that after 11th row the same value repeated.
plz help me with code and other method
You may want to look at this question which is the same problem. In that case, the person was setting the text of the cell only when creating a new cell (when nil was returned from [tableView dequeueReusableCellWithIdentifier:].) It needs to be set every time the tableView:cellForRowAtIndexPath: is called.
when you use reuseIdentifyer, the new cell to display is the cell that has just disappeared. so it will contain all the data from the disappeared cell. for example, if the cell, that has just disappeared, has detailDisclosureIndicator, the new cell will have it too even you don't set it.

UITableView: moving a row into an empty section

I have a UITableView with some empty sections. I'd like the user to be able to move a row into them using the standard edit mode controls. The only way I can do it so far is to have a dummy row in my "empty" sections and try to hide it by using tableView:heightForRowAtIndexPath: to give the dummy row a height of zero. This seems to leave it as a 1-pixel row. I can probably hide this by making a special type of cell that's just filled with [UIColor groupTableViewBackgroundColor], but is there a better way?
This is all in the grouped mode of UITableView.
UPDATE: Looks like moving rows into empty sections is possible without any tricks, but the "sensitivity" is bad enough that you DO need tricks in order to make it usable for general users (who won't be patient enough to slowly hover the row around the empty section until things click).
I found that in iOS 4.3, the dummy row needs to have a height of at least 1 pixel in order to give the desired effect of allowing a row to be moved into that section.
I also found that the dummy row is only needed in the first and last section; any sections in between don't have this problem.
And it looks like in iOS 5.0, no dummy rows or special tricks are needed at all.
While managing the edit, you can monitor if the table view is in Edit Mode. Use that flag inside of cellForRowAtIndexPath to decide weather or not to display the 'blank' row. While in 'regular' mode, the row will not display, but when the user taps 'edit' cellForRowAtIndexPath should get called again and this time decide to display the row. The details of how to do that depend on your data source and how you are gluing it to the display. If you aren't getting the call again, you can manually inject rows with insertRowsAtIndexPaths / deleteRowsAtIndexPaths and/or call reloadData to force a refresh.
I found that if you return -1.0 from the heightForRowAtIndexPath method it will remove the 1 pixel line.