how to get count of array outside tableview method swift

Viewed 39

I want to increase UIView size according to array count. Currently, I am doing this -:

var socialMediaURLSArray = [URL]()

and in View did load i am doing this -:

 viewHeightConstraints.constant = (60 * 1) + 170

In place of 1, I want to define socialMediaURLSArray count.

1 Answers

In place of 1, I want to define socialMediaURLSArray count.

so

viewHeightConstraints.constant = (60 * socialMediaURLSArray.count) + 170

You may need to to the above code inside the didSet of the socialMediaURLSArray to make it auto update.

You may need to call view.layoutIfNeeded() to update the constraint. Also you can perform it inside an animation block

Related