ios - Infinite Loop Event Handler Pairs -
i have 2 views have event handler in delegates called time interaction occurs. in each event hander i'd performs interaction on other view. issue here run infinite loop of , forth calls on event handlers i.e. when 1 interaction on other, triggers event handler, , on. there way around this?
here delegate method. view1 , view2 2 views. position custom class used update positions of each view.
-(void) viewdelegate: (uiview*) dview didchangeposition: (position*) newposition { if( dview == view1 ){ [view2 movetoposition: newposition]; }else{ [view1 movetoposition: newposition]; } }
at beginning of viewdelegate:didchangeposition:
save delegate of view1
and/or view2
local variables, , nil
out actual delegate properties. can freely call movetoposition:
or other code generate delegate callback. @ end of method restore delegates saved values.
Comments
Post a Comment