Poornima Mishra
Poornima Mishra

Reputation: 416

how to get count of array outside tableview method swift

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.

Upvotes: 1

Views: 47

Answers (1)

Mojtaba Hosseini
Mojtaba Hosseini

Reputation: 119310

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

Upvotes: 1

Related Questions