13
votes

I have created UITableView Cell Dynamic height with use of Autolayout and UITableViewAutomaticDimension.

Problem is that I use UImageView with height of 6 as separator. I set UImageView Top space margin (Vertical Spacing with its above UIButton (Button 2)) but in some situation I do not need to use UIButton(Button 2)

How I can disappear my UIButton(Button 2) and how I can establish UImageView Top space margin (Vertical Spacing with the above UILabel (Country)) because I cannot use UILabel (Desc) in some situation where I do not need UILabel (Desc)

According to API,

(1) UILabel Desc needed and UIButton(Button 2) not needed

(2) UILabel Desc not needed and UIButton(Button 2) needed

(3) UILabel Desc needed and UIButton(Button 2) needed (both needed)

(4) UILabel Desc not needed and UIButton(Button 2) not needed (both not needed)

UIImageView (Separator) come at the end of cell details

UILabel (Name) Compulsory I need

UILabel (Desc) Compulsory I need

UIImageView(Separator) Compulsory I need

Means, I want to make UIImageView(Separator) Top space margin (Vertical Spacing in best way so that I can see in all cell without any extra space between UILabel (Desc)

I have uploaded my project on below link

https://drive.google.com/file/d/0B5mabdphYDhzWG9UMzM2MTV6cms/view?usp=sharingenter image description here

2
Check the dynamic cell height using auto layout tutorial. You can copy the UIlabels and constraints from there. - pkc456
use your label 's no. of lines 0. - ajay_nasa
Show your layout design. - Bista
@ajay_nasa I Have already set all labels number of lines 0 Sometimes (1) UILabel Desc needed and UIButton(Button 2) not needed (1) UILabel Desc not needed and UIButton(Button 2) needed (1) UILabel Desc needed and UIButton(Button 2) needed both needed UIImageView (Separator) come at the end of cell details Thanks - Ankur Patel
@Mr.UB here layout design image link Thanks drive.google.com/file/d/0B5mabdphYDhzRHFmdWw2WEZraEU/… Thanks - Ankur Patel

2 Answers

5
votes

Please check this screen shot correct or not?

1> Button 2 doesn't need in first cell.

2> Desc doesn't need in second cell.

3> Button 2 and Desc both need in third cell. (First cell in Screen shot 2)

4> Button 2 and Desc both doesn't need.

Download Project this link: https://github.com/BhadreshKathiriya/AutoLayoutSignin

enter image description here enter image description here

1
votes

May I suggest the obvious solution of configuring several different cell layouts (each with its own own reuse identifier). Seems to me that would save you a lot of time in trying to figure out bizarre auto-layout issues.