Custom TableViewCell action?

Discussion in 'iOS Programming' started by Mvkoe, Jan 8, 2013.

  1. Mvkoe macrumors member

    Mvkoe

    Joined:
    Aug 4, 2008
    Location:
    Belgium
    #1
    Hey

    The question that I have is how is this "thing" called: (See figure 1)

    So basicly when the user tap the + next to the 1 option in the TableView. Then the information come's underneath it in the tableview. the + changes into a -.

    This is the process, and i want to know how this is called, it's not really a dropdown menu, because it's populating the TableView.

    Figure 1:
    [​IMG]
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    It's been years since I did anything fancy like this with UITables, but if I recall correctly there's a data source method that dictates whether a row should show a +, -, both, or neither during editing. There's also a delegate method that is called when the + or - button is pressed.

    I suspect that they have it set up to initially show a +, then when you press that + it inserts the two rows with animation, and changes the edit mode of the row from + to -. The table would be in edit mode the whole time. Alternatively, it's possible they just stuck in their own UIButton with the + sign and change it to a - at the right time.
     
  3. Mvkoe thread starter macrumors member

    Mvkoe

    Joined:
    Aug 4, 2008
    Location:
    Belgium
    #3
    And is it possible to add value's between other value's in my Array ?
    Like i would have an array:
    Person 1 +
    Person 2 +

    to:
    Person 1 +
    Things about person 1
    Person 2 +
     
  4. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    Yes, it is possible.

    If you're looking for more help with it, I suggest you start posting some code where you attempted to do this and we can point out mistakes you made.
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Sure, it's possible. But it seems to me that what your table is showing, based on the above example, is people. Without each row expanded, you're showing only minimal information for each person. When a row is expanded (through the use of an accessoryView button), you include more detailed information about that person in the row. Is that the case?

    If that's true, I would have an array of Person (model-class instances) as your data-source and then your unexpanded rows show only basic properties of the Person and expanded rows show more. You might need a parallel array to keep track of which rows are expanded.
     
  6. Mvkoe thread starter macrumors member

    Mvkoe

    Joined:
    Aug 4, 2008
    Location:
    Belgium
    #6
    I would have a plist file where i load my data from. The real data is like this:
    [​IMG]

    So an NSDictonary that hold's my Categories, and in each categorie there is an array of strings.
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Load the plist into your model layer. Then access from there.

    I still think you are trying to bite off more than you can chew. You need to concentrate on the fundamentals right now. Have you finished that book yet?
     
  8. Mvkoe thread starter macrumors member

    Mvkoe

    Joined:
    Aug 4, 2008
    Location:
    Belgium
    #8
    I'm always trying to think a bit further then I can handle, so I can learn from the things I want to acomplish. And yeah kinda done with the book

    So I already have my data categories in my Tableview, so in did select row, or an button, it should load the data from the array categorie and show it under the categorie like a "dropdown" menu.

    Can't you push me in the right direction of how need to handle this ?
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    Nothing wrong with that.

    Kinda done? What does that mean?

    Have you considered using a drill-down approach rather than a drop-down?

    By the way, I'm a little confused. First you were talking about Persons and now you are talking about Categories.
     
  10. Mvkoe thread starter macrumors member

    Mvkoe

    Joined:
    Aug 4, 2008
    Location:
    Belgium
    #10
    With kinda done i mean, i'm done with the things that are meant for me, so no iCloud, iPad, drawing Quartz stuff.

    Yea sorry i'm confusing you, the persons thing was an example from the screenshot, and that not really has to do with categories that I want. I just want the drill-down menu ?

    Correct me if i'm wrong. I'm thinking something like this:

    Code:
    didSelectRowAtIndex -> get label, search for that key string in my dictionary and get those value's -> Drill that down under the first categorie that it searched for? 
    How can i accomplish that drill-down ?
     
  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    You pretty much have the pseudo-code here. Now it's just a matter of translating that into actual code.

    P.S. When you say "get label" be careful not to try to get the actual UILabel that is displaying the text in the cell. Instead, you'll want to retrieve this value from your datasource.
     

Share This Page