Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have a similar issue: namely wanting to update only a portion of a UIView with a call to setNeedsDisplayInRect: which I pass a valid CGRect of the correct size (proved with Break Points, and Logs). Under iOS 4.2.1 (on my iPhone 3G) the UIView keeps its original image and only updates the portion specified by the CGRect, but under iOS 5.1 (on my iPhone 4S) the entire UIView is redrawn in transparent black (how black can be transparent is beyond me), with the area specified by the CGRect being drawn in correctly after. It seems to be either: an error on Apple's part that they are not implementing setNeedsDisplayInRect: correctly and just passing it to setNeedsDisplay:; or it was a wilful decision based on how the new iOS handles interaction with the actual screen architecture. Either way, it would seem that for the time being developers will either have to wear the cost of updating the entire UIView every time a graphical change occurs, or use some iOS detection and implement different screen drawing code depending on the iOS being dealt with.</p> <p>I have done some testing with the UIView property clearsContextBeforeDrawing (which according to the documentation should allow targeted drawing operations), but the results are identical for both YES and NO, so it would appear to be the implementation of the drawing code.</p> <p>As for the CGRect being of the incorrect size during updates: is it being set somewhere else prior to, or after, the drawing call. I set my CGRect just before the call to setNeedsDisplayInRect:, and then set it to CGRectNull on the last few lines of the drawRect method (this is so if the drawRect method is called by the system my code will not fire). After going back to your code snippet I can see it gets set in-line, which means it's a System Call that's redrawing the entire UIView, and hence why the CGRect is the entire view.</p> <p>I'll keep digging into this, but I fear that until Apple either disclose their reasoning for the change to setNeedsDisplayInRect:, or fix the apparent bug, we may be looking at updating the entire contents of a UIView for every graphical update (which could be potentially very 'expensive').</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload