Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I add 2 UITableView on 1 nib/UIView but using 2 different UITableViewController to handle?
    primarykey
    data
    text
    <p>How can I add 2 UITableView on 1 nib/UIView but using 2 different UITableViewController to handle ?</p> <p>Thanks for helping!</p> <hr> <p>Updated:</p> <hr> <p><strong>I understand the basic idea, but I just can't get it working together.</strong></p> <p><strong>Maybe it is a simple question, but for someone doesn't know, it is obviously a difficult one.</strong></p> <p><strong>Anyone can help trouble shooting a little bit?</strong> </p> <p>I created a view based application named "MutiTableView",then drag &amp; drop 2 TableView into the nib.</p> <p>This is the generate ViewController, I add 2 IBOutlet in order to connect with 2 tables in the nib.</p> <pre><code>@class FirstTableViewController; @class SecondTableViewController; @interface MutiTableViewViewController : UIViewController { UITableView *tablefirst; UITableView *tablesecond; FirstTableViewController *firstController; SecondTableViewController *secondController; } //@property (nonatomic, retain) IBOutlet Table1ViewController *viewController; @property (nonatomic, retain) IBOutlet UITableView *tablefirst; @property (nonatomic, retain) IBOutlet UITableView *tablesecond; @property (nonatomic, retain) FirstTableViewController *firstController; @property (nonatomic, retain) SecondTableViewController *secondController; </code></pre> <p>This is how I set the datasource and delegate </p> <pre><code>- (void)viewDidLoad { NSLog(@"viewDidLoad :("); firstController = [[FirstTableViewController alloc] initWithStyle:UITableViewStylePlain]; secondController = [[SecondTableViewController alloc] initWithStyle:UITableViewStylePlain]; tablefirst.delegate = firstController; tablefirst.dataSource = firstController; tablesecond.delegate = secondController; tablesecond.dataSource = secondController; [super viewDidLoad]; } </code></pre> <p>This is my FirstTableViewController, it is just a basic tableViewController</p> <pre><code>@interface FirstTableViewController : UITableViewController { NSArray *listData; } @property (nonatomic,retain) NSArray * listData; @end #import "FirstTableViewController.h" @implementation FirstTableViewController @synthesize listData; /* - (id)initWithStyle:(UITableViewStyle)style { // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. if (self = [super initWithStyle:style]) { } return self; } */ - (void)viewDidLoad { NSLog(@"FirstTableViewController viewDidLoad"); NSArray * array = [[NSArray alloc] initWithObjects:@"111",@"222",@"333",@"444",@"555",@"666",@"777",@"888",@"999",@"000",nil]; self.listData = array; [array release]; [super viewDidLoad]; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } ..... </code></pre> <p>I also implemented the methods like following.</p> <pre><code>numberOfSectionsInTableView tableView:numberOfRowsInSection: tableView:cellForRowAtIndexPath: </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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