2
votes

I noticed in IOS5 when calling SetNeedsDisplayInRect for the first time, it causes the device to refresh the full-screen. this is different to previous IOS-Versions.

In the App I am working on I have an array of objects that needs to be drawn (mostly rectangles, with different line sizes). In case I want to redraw only a few rectangles I add the objects to an "Update"-Array and call SetNeedsDisplayInRect to invalidate the area of the rectangles.

inside my drawRect-Method I determine like this, to either draw the complete array of objects, or just the "Update-Array":

BOOL boolDrawFullScreen = CGRectEqualToRect(rect, self.frame);

if (boolDrawFullScreen)
//draw all the objects
else
//draw just the objects within the update-array

this worked perfectly until I tested it with IOS5. In fact it still works, but not the first time when calling SetNeedsDisplayInRect:--> CGRectEqualToRect returns always yes.

why is that?? what am I doing wrong?

any suggestions are highly appreciated!! Thanks

Tom

1
This seems like a bug in iOS5 - I am running into it too.spring

1 Answers

2
votes

This behavior is documented here in QA1708 Improving Image Drawing Performance on iOS

Note that, because of the way that iPhone/iPod touch/iPad updates its screen, the entire view will be redrawn if you call -setNeedsDisplayInRect: or -setNeedsDisplay:.

So it seems you'll want to use a subview if you have screen sub rect that should update independent of the rest of the screen.