setNeedsDisplay works on iPhone but not iPad

Discussion in 'iOS Programming' started by John Baughman, Nov 5, 2011.

  1. John Baughman macrumors regular

    Oct 27, 2003
    The view in question was created in IB on the root view and wired to a class method in the rootViewController. In the view's class method I am overriding drawRect to draw it's content. I am calling setNeedsDisplay on the view from the rootViewController after the user changes some parameters.

    On the iPhone this works fine. On the iPad, however, drawRect in the class method does not get called.

    I suspect that the reason for this has to do with the drawing cycle. On the iPhone the view used by the user to change the parameters is pushed onto the screen over the view in question. On the iPad this view is added to the root view above, not over, the view in question. So when the view used to change the parameters is closed, unlike on the iPhone, a drawing cycle is not generated and so the invalidated view is not updated.

    I'm stuck. Any help would be appreciaetd.
  2. John Baughman thread starter macrumors regular

    Oct 27, 2003
    Found the problem

    I discovered that in the xib being used by the root view controller for the iPad, the wiring for the UIView object in question was some how corrupted. When I hovered over the bullet of it's iIBOutlet variable in the .h file an UISegmentedControl elsewhere in the xib would be selected instead of the intended UIView. Right-Clicking the UISegmentedControl did not show that the link existed. The only way I was able to get it fixed was to remove all the wiring from both objects and rewire them properly. Calling setNeedsDisplay now works. as expected, on the iPad just like it does on the iPhone.

Share This Page