UIView Issue

Discussion in 'iOS Programming' started by GhostDZ9, May 20, 2011.

  1. macrumors regular

    Sep 13, 2010
    Hey guys,

    So im building another part to my app and i can't get it to display properly

    What I have:

    - I have a navigation bar at the top that has the app name
    - I have a button to start the timer
    - I have a UITableView to show 6 options
    - A date picker at the bottom of the app in the form of a timer

    My issue is:

    When I create a new file without a subclass of a UITableView

    I can edit the .xib file and put whatever I want on it but they array doesn't populate on the TableView


    When I create a new file with a subclass of UITableView

    I can't edit the .xib file and put whatever i want but they array populates the UITableView


  2. Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Do you have a subclass of UIViewController for your view? You should. And when you do, you can make it the delegate and datasource for your UITableView.
  3. macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    Like Dejo said.

    If u add a UITableView in a blank UIView Controller, u have to add delegates (Objective C thing.)

    In your Header file, u can do like this

     blahblah : UIViewController <UITableViewDelegate, UITableViewDatasource> 
    Or something. Then in your XIB, add the tableview, control click it, drag it to files owner, show it the delegate/datasource. Then it will populate it accordingly, if u add the code right ;)
  4. macrumors 68030


    Sep 2, 2008
    I think you're running into a limitation of UITableViewController. It requires that its table is fullscreen. If you want a tableview that is smaller than fullscreen you need to use your own subclass of UIViewController. What I usually do is create a new file and choose UITableViewController and then change the base class to UIViewController. In this way I get all of the tableviewcontroller methods in the .m file.
  5. thread starter macrumors regular

    Sep 13, 2010
    How would I go about doing that?
  6. macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    That's kind off how I said..
    Add a new file, a UIVIewController, and then u can select if u want it to be a UIVIewController subclass or a UITableViewController. choose the latter, then, in the header file, change it to how i said it, u have the methods and the XIB to go on..
    But create a new UIView, drag the existing tableview in there. and on the file's owner, instead of giving the tableview the "view" property, give it to the UIView.

    Or grab a book if u didn't understand what we just proposed :p

Share This Page