iphone - Subclassed UIView doesn't get tag set -
i have subclassed uiview
class , create multiple instances of class in loop (incrementing each time), when try set tag of view, , log console after created, have tag of 1, regardless of set tag as.
any appreciated, thanks!
my code creating subview here:
//for() loop above counter flashcardview *subview = [[flashcardview alloc] initwithframe:frame]; subview.delegate = self; subview.viewnum=i+10; //my attempt @ workaround cannot view later not helpful [subview settag:i+10]; //tried , subview.tag=i+10; nslog(@"%d", subview.tag); //prints correctly //gets added parent later
this nslog
logs correct tag, when log tag in uiview
subclass, returns tag 1
. also, if print subviews of parent in later called method (in viewcontroller
), of them have tag 1.
i cannot tell why, can tell how find problem. in flashcardview subclass, add method:
- (void)settag:(nsinteger)thetag { assert(thetag != 1); [super settag:thetag]; }
then, when whatever setting tag 1 it, assert fire , can @ stack trace , see coming from.
alternately, remove assert, , put breakpoint on super message.
ps: make sure enable exceptions!
Comments
Post a Comment