I have this question on the TableViewCell.I wanna put a picture on the cell,and then the height of cell will be changed depend on the picture’s height. How can I code this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You probably have an
UIImageViewinside your cell. That image view has an UIImage, and the UIImage has a size property that you can use to detect the image height.Using
UITableView‘s heightForRowAtIndexPath method, as mentioned by psoft, you can tell your cell to change its height according to your image.Using
all your cell will have a height of 100 pixels. If you change that function and make it return the height of the image in your cell, you will solve your problem