Resolved XCode 4 + Custom UITableViewCell Problem

Discussion in 'iOS Programming' started by CBX, Jan 18, 2012.

  1. CBX, Jan 18, 2012
    Last edited: Jan 19, 2012

    CBX macrumors regular

    Joined:
    May 15, 2007
    #1
    Hi:

    Im totally new to Xcode but not new to software development. Im currently looking at the Storyboard option to create a new screen using a UITableViewController.

    My TableView has 1 section and 2 rows which I want to store settings from NSUserDefaults. Each row has a label and a textbox.

    I have labeled the rows so they can be uniquely identified, however when I run I get no errors but the label and text box's don't show.

    However, if I change the controller to be a TableUIViewController (rather than using my subclass) it works fine...

    I subclass is just a standard subclass.

    Anyone help?
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Perhaps some code would help.
     
  3. CBX thread starter macrumors regular

    Joined:
    May 15, 2007
    #3
    Not sure what code I could show to help as everything is done through the storyboard resulting in no code?

    My screen doesn't populate the cells yet. There's just labels and text fields which don't show unless I change the view controller to the actual tvc rather than my subclass.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Cell population is done via code, regardless of whether you're using storyboards or not. And your concern seems to be with the labels and textfields not showing. So, perhaps the code that does this in your subclass compared to the code that does this in your tvc would be a good place to start.
     
  5. CBX thread starter macrumors regular

    Joined:
    May 15, 2007
    #5
    Appreciate what your saying. Maybe I have the wrong idea.

    The only code in my sub class is the auto generate sub class code. The only change I made is to the two methods which return num of rows and num of sections.

    I'm not populating the text boxes at this stage but would still expect to see my labels show up as in the storyboard.

    Perhaps I'm missing a bit of knowledge. However it does work if I use a tvc rather than a sub class of it.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    What leads you to this conclusion? What is your understanding of how this is supposed to work? What have you done to confirm it?
     
  7. CBX thread starter macrumors regular

    Joined:
    May 15, 2007
    #7
    My understanding is if I drop a static element on to a ui designer it should appear when I run it.

    I would not expect to see dynamic content.

    What am I missing in my understanding?
     
  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    Perhaps I'm not understanding. By static element, do you mean a UILabel? Where in your UI are you dropping this label? Does this label have a text value?

    Could you perhaps include a screenshot of your UI setup?
     
  9. CBX thread starter macrumors regular

    Joined:
    May 15, 2007
    #9
    Static element, yes a ui label set to a value.

    Sorry. Away from MacBook at moment so can't screen shot.

    Thanks for help with this.
     
  10. CBX thread starter macrumors regular

    Joined:
    May 15, 2007
    #10
    Resolved!! :)

    Thanks for your help with this, refocusing be back to the code.

    It turns out that the auto generate code when I subclassed the TVC was the issue.

    Commenting out

    - (NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection: (NSInteger)section

    now allows my static rows with custom cells to display.

    I assumed that the stub code would not be the issue.
     
  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  12. CBX thread starter macrumors regular

    Joined:
    May 15, 2007
    #12
    I was looking for how to change the thread title. Hadn't seen this.

    Im on it :)
     
  13. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #13
    It's a Sticky at the top of this very forum. Be sure you've checked out the others and the Guides as well.
     

Share This Page