views:

127

answers:

1

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:CGPointMake(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]];

}
+1  A: 

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.

Ole Begemann
Thanks for the quick response. The problem lies in me using the tag property to decide which view controller to push based on the value of `animalNameString` ...Is there another way I can do that in `didSelectRowAtIndexPath:`?
iWasRobbed
Figured it out, thanks Ole
iWasRobbed