UITableViewController not receiving events

Discussion in 'iOS Programming' started by Tiiba, Jul 9, 2010.

  1. Tiiba macrumors newbie

    Jul 9, 2010
    I am still new to the iPhone SDK, and I find it pretty confusing. I have, until now, only used managed languages like Java, C#, VB.NET, and some Python.

    Here's code that adds a table to the screen. The table shows up on the screen, but its contents do not. The methods that should fill them in are never entered.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    // Override point for customization after app launch. 
    tv = [[UITableView allocinitWithFrame:CGRectMake(2020500500style:UITableViewStylePlain];
    tableController = [[*descendent of UITableViewControllerallocinit];
    tv.delegate tableController;
    //tv.backgroundColor = [UIColor greenColor];
    [window addSubview:tv];
    window makeKeyAndVisible];

    Here's one of the methods that refuses to be called in the delegate:

    - (void)viewDidLoad
    super viewDidLoad];
    // Configure the table view.
    self.tableView.rowHeight 73.0;
    self.tableView.backgroundColor DARK_BACKGROUND;
    Entry point:

    #import <UIKit/UIKit.h>

    int main(int argcchar *argv[]) {
    NSAutoreleasePool pool = [[NSAutoreleasePool allocinit];
    int retVal UIApplicationMain(argcargvnil, @"*Implementor of UIApplicationDelegate*");
    pool release];
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Don't do it like that. UITableViewController makes its own table. Don't try to associate a view controller with a view like this. If possible try not to add views directly to a window. (I know that it has to be done once at the start of an app.)

    Start with the NavBar app from template. It shows how to do this and it works. If you don't want to see a navbar then make it hidden. You will save yourself a lot of grief if you use a navbar controller.
  3. forum user macrumors regular

    Aug 28, 2008
    And set self.tableView.rowHeight = 73.0;
    as a return value in
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
    That's part of the UITableViewController.

Share This Page