Creating UITableViewCell with add photo button like in Contacts app
When you add a 开发者_开发百科new contact, the first row contains the add photo button and the x co-ordinate of start of the cell is set to some value which is greater than the rest of the cells. How can this photo button be added and the cell frame can be changed?
Thanks!
They use a custom cell to achieve this. This custom cell has the picture-like control on the left and mimics a table cell next to it. It's not something that comes out of the box.
You can't set the x co-ordinate of a cell either, you can set the indentation on the other hand.
Edit: come to think about it, they probably use a custom table header instead of a custom cell. You certainly will find the headerfooter sample on developer.apple.com helpful.
Link: https://developer.apple.com/library/archive/samplecode/HeaderFooter/Introduction/Intro.html
I am more inclined to believe that they use tableHeaderView property.
Sure you can achieve the effect with custom cell. But with header its pretty simple! I have done the same in few places!
精彩评论