Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading