Help ! Problem with UIViews.

Discussion in 'iOS Programming' started by cthesky, Sep 29, 2011.

  1. cthesky macrumors member

    Joined:
    Aug 21, 2011
    #1
    Hi,

    I faced some problems when developing my Iphone project. Really hope anyone can give some ideas. Below is the scenario:

    1.) My project have a login page with a text field named as name and a button beside this text field.

    2.) Once click that button, a pop up list (in this case I display the pop up list as a table list) which consists a list of names will be displayed.

    - I am using - (void)insertSubview: (UIView *)view aboveSubview: (UIView *)siblingSubview method to display that pop up list.

    3.) User can choose one of the names then click "Done" button at the bottom of pop up list.

    4.) Once click that "Done" button, the pop up list will be removed and show up that login page. The name selected by user just now must be passed and displayed in the text field in login page.

    - I using - (void)removeFromSuperview method the remove that pop up
    list.

    - I get the value from pop up list and set to the text field.


    But now what I get is I can't pass that name value from pop up list to text field. It seems the text field and the login page does not "refresh" or "redraw" as I am using removeFromSuperview method.

    Am I using the wrong way to display all the views? Anyone has any idea to pass the value from pop up list to the login page as I am doing now?

    I had attached a sample view for this scenario.

    Really Thanks for any help. :)
     

    Attached Files:

  2. jonnymo5 macrumors 6502

    Joined:
    Jan 21, 2008
    Location:
    Texas
    #2
    I would use delegation. Create a simple protocol for your popup list with a method that will accept the name you want to pass back. Then you have your login page view controller implement the protocol and assign itself as the delegate. Then when you select the done button on your list view have it call the method on it's delegate (the login page).

    Here is a quick example I found.
    http://www.ios-developer.net/iphone-ipad-programmer/development/delegates/how-to-create-a-delegate

    I use this method a lot for "picker" type views.
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    You might want to consider either a modal view for your popup or, if it has limited choices, a UIActionSheet.
     
  4. cthesky thread starter macrumors member

    Joined:
    Aug 21, 2011
    #4
    Hi Jonnymo5,

    Thanks a lot for your reply and help. It works !!! I can pass the value from pop up list back to the text field of login page. Thanks a lot !!!. :)

    ----------

    Hi Dejo,

    Thanks for your reply. Ok. I will try to use modal view for my pop up list since my pop up list displays data dynamically instead of has limited choices. :)
     
  5. cthesky thread starter macrumors member

    Joined:
    Aug 21, 2011
    #5
    Hi,

    One more question. The pop up name list as shown in attached image need displays data (name1, name2, name3) dynamically. So, firstly I plan display this pop up list as a table list as shown in image. But is it a correct way to display a dynamic pop up list? or should it display as a picker view? which one is more better (table list or picker view)?

    Thanks for any ideas and suggestions. :)
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    You can still use UIActionSheet, even if your choices are dynamic, as long as the number of choices is limited.
     
  7. cthesky thread starter macrumors member

    Joined:
    Aug 21, 2011
    #7
    ok. Thanks for your help. I will try it. :)
     

Share This Page