Monday, November 02, 2009

iPhone dev Stupidity 94: Delete content of scrollview when scroll

If you delete the content view of a UIScrollView in:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView


later there's still some animation work need to be done by cocoa, and the error will happen (note that ScrollerHeartbeatCallback):



A Hack to solve - delayed remove:

// !!! a hack


// directly remove container from superview, later there's some heart beat callback for smoothing the scrolling


// which will still trying to use the old scroller, and when fails to find, there'll be a BAD ACCESS failure


// here we just delay the remove.


container.alpha = 0.0;


[container performSelector: @selector(removeFromSuperview) withObject: nil afterDelay: 0.1];


No comments: