13

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=sharing

enter image description here

Dan Bonachea
  • 2,408
  • 5
  • 16
  • 31
Ankur Patel
  • 477
  • 5
  • 19
  • [Check](http://www.programmingcrew.in/2015/09/uitable-view-cell-dynamic-height-ios7.html) the dynamic cell height using auto layout tutorial. You can copy the `UIlabels` and `constraints` from there. – pkc456 Sep 09 '16 at 07:41
  • use your label 's no. of lines 0. – ajay_nasa Sep 09 '16 at 07:43
  • Show your layout design. – Bista Sep 09 '16 at 07:55
  • @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 Sep 09 '16 at 07:56
  • @Mr.UB here layout design image link Thanks https://drive.google.com/file/d/0B5mabdphYDhzRHFmdWw2WEZraEU/view?usp=sharing Thanks – Ankur Patel Sep 09 '16 at 08:02
  • @BhadreshKathiriya Button2 Height is fix in some cell I need Button 2 and other cell I do not need Button 2 UILabel Desc size is dynamic but in some cell I need UILabel Desc and other cell I do not need UILabel Desc Case is below (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) – Ankur Patel Sep 09 '16 at 09:38

2 Answers2

5

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

Bhadresh Kathiriya
  • 3,147
  • 2
  • 21
  • 41
  • nice perfect but I need same padding after 1> Button 2 doesn't need in first cell. Fox Ex 10 pixel padding between Description and UIImageView Separator 2> Desc doesn't need in second cell. Fox Ex 10 pixel padding between Lavel Country and UIButton (Button 2) 3> Button 2 and Desc both need in third cell. (First cell in Screen shot 2) It is perfect 4> Button 2 and Desc both doesn't need. Fox Ex 10 pixel padding between Lavel Country and UIImageView Separator – Ankur Patel Sep 09 '16 at 10:00
  • which index after padding? – Bhadresh Kathiriya Sep 09 '16 at 10:01
  • nice good work is there any solution on same padding in above 4 case – Ankur Patel Sep 09 '16 at 10:03
  • nice perfect but I need same padding after 1> Button 2 doesn't need in first cell. Fox Example 10 pixel padding between UILabel Description and UIImageView Separator 2> Desc doesn't need in second cell. Fox Example 10 pixel padding between UILabel Country and UIButton (Button 2) 3> Button 2 and Desc both need in third cell. (First cell in Screen shot 2) It is perfect 4> Button 2 and Desc both doesn't need. Fox Example 10 pixel padding between UILavel Country and UIImageView Separator – Ankur Patel Sep 09 '16 at 10:14
  • Please my screen shot edit that check all padding in 10 pixel. 1 screen shot check cell 1 and 2. 2 screen shot check cell 1(3) and 2(4). – Bhadresh Kathiriya Sep 09 '16 at 10:17
  • Download project above link zip file declare. – Bhadresh Kathiriya Sep 09 '16 at 10:25
  • Sorry bro i can not get your updated project above zip link i got my old project can you create new download link otherwise send me on my email id anks.patel62@gmail.com Sorry for inconvenience – Ankur Patel Sep 09 '16 at 10:45
  • me change your project. – Bhadresh Kathiriya Sep 09 '16 at 10:50
1

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.

cbiggin
  • 1,942
  • 1
  • 17
  • 18
  • Hi cbiggin thanks for your response it is very glad for me if you provide better solution, continue you can provide your solution. Thanks – Ankur Patel Oct 06 '16 at 04:28