How would you approach hiding multiple text fields and buttons?

Discussion in 'iOS Programming' started by chrono1081, Jul 13, 2014.

  1. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #1
    Hi guys,

    I have an app I'm working on and I have a form with a segmented control at the top and based on the button selected on the segmented control it needs to hide certain text fields on the form.

    When some of those text fields are hidden, the ones below the hidden fields need to move up and fill in the space the hidden fields left behind.

    My question is is there an elegant way to do this using maybe constraints, or some property?

    Or do you think it would be better to maybe dynamically load a new view based on the selection?

    I haven't found much documentation suggesting how one may approach this.
     
  2. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #2
    I'm sure there is a Viewcontroller to do sort of what you want but that might require completely separate views so data the user has inputted might be lost in the transition.

    I would suggest a Tableview, just because I use them a lot and might overlook better solution in favour of them. As the user switches segment test if the data that should be removed has a cell in the table and remove those cells, add in any that should be added. Tableview animates everything in to place for you.
     
  3. JohnsonK macrumors regular

    Joined:
    Mar 6, 2014
    #3
    I would suggest UICollectionView instead of UITableView. They are much more flexible
     
  4. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    There's a library someone else made and posted on github that can handle all this stuff very well. If only this were Python or Ruby or Racket or any other language where adding third party libraries was trivial or I'd strongly recommend it (and no, Cocoa Pods isn't acceptable. Not at all. I tried that once. Ended up with a lot of compilation errors and just threw it out).
     
  5. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    A tableview or collection view is one likely choice. Look at Settings.app and see if there's something in there that works the way you want to serve as a model. It all seems to be tableview based. There's also some apple sample code that shows various ways to add/remove rows dynamically.
     
  6. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #6
    An app I'm currently working with, decided to go with a scroll view and manually hiding fields not to be displayed and adjusting the frames for those they wanted to show in short mode. There isn't any animation between the two modes but that doesn't seem to be a big deal. The switch is at the top of scroll view.
     
  7. chrono1081 thread starter macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #7
    Thanks guys for all of the suggestions :)

    I'm not allowed to use any external libraries for this project (sorry I should have clarified that) but I'll give the other options a look.

    Thanks again.
     

Share This Page