I'm trying to make a cell that looks just like Apple's UITableViewCellStyleSubtitle, except the textLabel is a UITextView (so it can be edited). I just se开发者_高级运维t the textLabel to " " (so that the detailTextView is in the right place) and park a UITextView on top of it. So far, so good. It's working except that I can't quite get my UITextView to line up with the other textLabels of the other cells. I'm a tad off (in more ways than one...).
So that got me wondering: is there a way to get the frame of the various bits of a UITableViewCellStyleSubtitle cell? The obvious (or seemingly-obvious) way does't work. cell.textLabel.frame
returns nil, and if you print it, it shows (0, 0, 0, 0) for its frame. Maybe there's another way.
I realize I could hardcode it, but I'm still guessing what those dimensions might be. Programmatically would be nicer... I think.
Thoughts?
Thanks,
BillA view's frame isn't valid if the view's transform is not the identity transform. I haven't tried it, but you might be able to duplicate the positions of the elements this way:
- store the cell's transform
- set the cell's transform to CGAffineTransformIdentity
- get the frames of the elements
- set your own elements with the same frames
- apply the original transform to your cell
It'd be interesting to know if that works -- please post back if you have good luck.
精彩评论