Displaying block text in place of a UITableView

Discussion in 'iOS Programming' started by cnstoll, Nov 5, 2010.

  1. cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #1
    An app i'm working on uses a UITableViewController in a few places to display a list of data. The elements are objects that a user adds and the default state of the table is blank. Each element that is added becomes an option for a NavigationController.

    Currently in the default state with a blank table it's not immediately obvious to my test users that they should add an element. The method of data entry is a "+" button on the top right, but I think a brief instruction in the main window would help a lot.

    So what I'd like to do is display a short explanation of the purpose of that section to the user. Basically "Please click the + icon to add an entry". I'd like that text to only display when the table has zero elements.


    What I was thinking about trying was maybe something in the viewController's viewDidLoad or viewWillAppear method that checks if the data source has zero elements, and then replace the tableView object with some sort of textView or UIView with just some basic text. Maybe that's the right way of doing it, but I'm really not sure.

    If someone could just point me in the right direction here, I'm sure I can figure out the implementation details myself, if there is a good way of doing this.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    I would consider either presenting a modal view with the hint or perhaps, even better yet, a simple UIAlertView.
     
  3. cnstoll thread starter macrumors 6502

    Joined:
    Aug 29, 2010
    #3
    I experimented with the AlertView at first, but it wasn't really happy with the results. I've seen a few apps that do what I'm talking about. I guess I could do it as a conditional background image of some sort for the TableView. I haven't looked into that yet either. Right now I'm still in the "brainstorming" phase for this feature.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    A UITableView is just a subclass of UIView and you are free to add any subviews you want to it. That is, don't worry about manipulating the table itself.
     
  5. cnstoll thread starter macrumors 6502

    Joined:
    Aug 29, 2010
    #5
    Oh, duh. Ok, I think I know what I need to do now. Thanks :)
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    I kind of hate alerts. They mostly just get in the way and people often hit the ok button without reading them. An expert user of your app will hate having to do that every time.

    Few suggestions:

    Forget about this problem. Your users will figure out that they have to hit the + button and once they figure it out they will never forget it. If your app looks like Contacts.app I think they'll figure it out.

    Add a row to your table that displays in grey text the message you want to convey "Touch the add button to, um, add stuff" The row with the grey text doesn't do anything when tapped and is only shown when the table has no other content.

    You could change + to "Add" or something else more descriptive.
     
  7. cnstoll thread starter macrumors 6502

    Joined:
    Aug 29, 2010
    #7
    I'm think i'm going to either go with your second option, or have the tableview display a subview with instructions when there's nothing in the table. I'll just see which one works better. But yeah, it will definitely be something that once there's data it will never get seen again.
     

Share This Page