UIButton

Discussion in 'iOS Programming' started by Nnavick, Oct 13, 2010.

  1. Nnavick macrumors regular

    Joined:
    Oct 13, 2010
    #1
    Hi all,
    I created a timer that connect to a method that creates buttons.
    Evrey time the methods is running it overriding the last button and create new one(but keeps the old one active on screen).
    In C# when you want to point to an the obcject you click on it you'r writing
    PHP:
    this.bla bla;
    there is parallel function in objective C/Cocoa Touch that mean the same as "THIS"?(maybe "SELF")?

    Thanks !!
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    There is self but I suspect that's not what you're wanting. Do you want a pointer to the UI object that triggered the action?

    Also, what is your experience level with Objective-C and Cocoa Touch programming? What have you done to educate yourself on the fundamentals?
     
  3. Nnavick thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #3
    I started to program a month ago, but I think my level is pretty good.
    I have already set a target method that increase points when you click on the object(UIbutton).
    what i meant is that when you click the button, the method tell the APP that you clicked the currently button that already override and remove it from super view, actually it's what you said,
    so I tried
    PHP:
    [Self RemoveFromSuperView]
    but it changed the background to white,I think it has removed the UIVIEW.

    Do you have any idea how to point to the currently button I click on it?
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Based on your other thread, I see you've learned how to use addTarget:action:forControlEvents:. So, when you have your action method set up like so:
    Code:
    - (void)action:(id)sender {
    what do you think sender is?
     
  5. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #5
    PHP:
    [Self RemoveFromSuperView]



    Even if self was UIButton this would still fail. Check your case.


    Do not rush your learning. This is the reason I ask if you understood the code.
     
  6. Nnavick thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #6
    I think sender could be used to verify identity of the object, but I am not sure if I understood.
    I mean,i know what is the method behind sender but not sure if I understood is well
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Yeah, unfortunately, I don't think you are understanding it either. You don't appear to have a good enough grasp of the basic fundamentals of iPhone programming and Cocoa Touch. I would suggest you step back from the real coding for now and go (re)learn those before you continue with your app.
     
  8. Nnavick thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #8
    It's the only thing that missing in my APP ,anyway I will relearn the basic.
    hmm,what I am trying to do is possible?
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    No. In fact, not only is it quite possible, it's also quite common.
     
  10. Nnavick thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #10
    Sorry,I didn't ֿֿֿ understand what you mean.
    Is it possible or not?
     
  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    Oops. Sorry. Not sure why I typed that. What I meant to say was:
    Yes, it is possible.
     
  12. Nnavick thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #12
    haaaaaaaaaaaaaaaaaaaaaaaa
    I tried to write
    PHP:
    sender removeFromSuperview];
    and it's works,because the function takes the ID of the button(every button has special attribute) and place the ID at the Sender argument,
    so if I am turning to the Sender it's takes the attribute of the current button I clicked on it the remove the button from the view
     
  13. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #13
    Well, that's not how I would phrase it. sender is being set to a pointer to the object that triggered the action. You've just defined the method to accept the generic-type of id rather than a specific datatype, such as UIButton*.

    But I'm glad you got your code working, through your own process of discovery.
     

Share This Page