Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>UITableViewController</code> doesn't allow you to add subviews to it's view (the tableView).</p> <p>You should make a <code>UIViewController</code> and add the <code>UITableView</code> yourself with your optional <code>emptyView</code>.</p> <p>Don't forget to set the <code>dataSource</code> and the <code>delegate</code>!</p> <p>Update : I've made a subclass of UIViewController to avoid mimics UITableViewController every time.</p> <p>.h </p> <pre><code>// // GCTableViewController.h // GCLibrary // // Created by Guillaume Campagna on 10-06-17. // Copyright 2010 LittleKiwi. All rights reserved. // #import &lt;UIKit/UIKit.h&gt; //Subclass of UIViewController that mimicks the UITableViewController except that the tableView is a subview of self.view and allow change of the frame of the tableView @interface GCTableViewController : UIViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; @property (nonatomic, readonly) UITableView *tableView; - (id) initWithStyle:(UITableViewStyle)style; //Subclass if you want to change the type of tableView. The tableView will be automatically placed later - (UITableView*) tableViewWithStyle:(UITableViewStyle) style; @end </code></pre> <p>.m</p> <pre><code>// // GCTableViewController.m // GCLibrary // // Created by Guillaume Campagna on 10-06-17. // Copyright 2010 LittleKiwi. All rights reserved. // #import "GCTableViewController.h" @implementation GCTableViewController @synthesize tableView; - (id) initWithStyle:(UITableViewStyle) style { if (self = [super initWithNibName:nil bundle:nil]) { tableView = [[self tableViewWithStyle:style] retain]; self.tableView.delegate = self; self.tableView.dataSource = self; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self.view addSubview:self.tableView]; self.tableView.frame = self.view.bounds; self.tableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); } - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]; } #pragma mark TableView methods - (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger) tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section { return 0; } - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { return nil; } #pragma mark Getter - (UITableView *) tableViewWithStyle:(UITableViewStyle)style { return [[[UITableView alloc] initWithFrame:CGRectZero style:style] autorelease]; } - (void)dealloc { [tableView release]; tableView = nil; [super dealloc]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload