开发者

Set tag and hidden for objects on custom UITableViewCell

I am re-using Apple's AdvancedTableViewCells example to create a custom, fast-scrolling tableview. Specifically, I am using their CompositeSubviewBasedApplicationCell method which draws the content on the tableviewcell with drawRect

Everything works, but how do you hide a label or set the tag for a label or image using their method? Doing it this way is pretty new to me (without IB), so I apologize ahead of time if it's something easy.

The code that sets the cell content is:

- (void)drawRect:(CGRect)rect
{

[_cell.animalIcon drawAtPoint:CGPoint开发者_JAVA技巧Make(5.0, 5.0)];

[_cell.animalName drawAtPoint:CGPointMake(93.0, 25.0)];

_highlighted ? [[UIColor whiteColor] set] : [[UIColor colorWithWhite:0.23 alpha:1.0] set];
[_cell.animalDescription drawAtPoint:CGPointMake(100.0, 54.0) withFont:[UIFont boldSystemFontOfSize:13.0]];

[_cell.animalNameString drawAtPoint:CGPointMake(93.0, 5.0) withFont:[UIFont boldSystemFontOfSize:13.0]];

}


tag and hidden are properties of UIView. Since you are not dealing with instances of UIView anymore (you don't have UILabels or UIImageViews, just NSStrings or UIImages), they don't have a tag property. If you want to hide a specific part of text, just don't draw it in drawRect:. Use a simple if statement to test for whatever condition you need to determine whether the text should be drawn or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜