Home > Iphone Developer > Stanford Assignment 3 HelloPoly: 1 Control/Multiple Actions

Stanford Assignment 3 HelloPoly: 1 Control/Multiple Actions

I should have known this from my experience in Flash!  The solution to why it only draws the first polygon is that the same buttons, Increase and Decrease, required multiple, in this case 2, actions, not just one.  Basically you need to define another method, inside the polygonview, which calls setNeedsDispaly.  And hook up the same buttons in the nib file to that method.

  1. Hirad
    August 13, 2009 at 6:44 pm | #1

    I’m assuming you’re talking about the issue where the first polygon is drawn and then it doesn’t update with the increase/decrease buttons? If so, that’s because the instance of PolygonShape (or whatever your basic polygon class is) is different in the controller than it is in the view. You’re implementing all those increase/decrease methods again for a different instance. I did it by making the instance in the view a property and setting it to the controller’s instance, but what I really want to know is how I can make them the same instance. I tried connecting the view’s PolygonShape class in IB to the same PolygonShape class that the controller was hooked up to but they were still different instances.

    • marskoko
      August 13, 2009 at 8:48 pm | #2

      Hirad, actually the post is an answer to why it wasn’t working. I figured it out; basically I just wasn’t updating the viewcontroller via setNeedsDisplay. My buttons updated the model thru the increase/decrease methods but didn’t call the setNeedsDisplay method of drawRect and that’s what I was missing in my code.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 248 other followers