Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 8, 2012, 12:28 AM   #1
Fritzables
macrumors regular
 
Join Date: May 2011
Location: Brisbane AUSTRALIA
Two TableViews in a single ViewController ??

Hi All,

I am writing an application suitable to Maintenance Planning.

The application is for the iPad (Only) and using the latest XCode 4.3.3 and StoryBoards.

In the past my applications have only had a single UITableView for each ViewController, so setting delegates and datasources or even control Row Height and other parameters reasonably straight forward.

Now, there is a need to have a ViewController that contains two TableViews as shown in the attached file.

As you can see I have placed the GUI TableViews onto the ViewController and have not placed them there programatically.

To gain access to the Tables parameters and properties I have declared the UITableView in the Header for the ViewController:

Code:
@interface VehicleViewController : UIViewController {
 
    UITableView *listVehicle;
    UITableView *listMaintenance;
}

@property (nonatomic, retain) IBOutlet UITableView *listVehicle;
@property (nonatomic, retain) IBOutlet UITableView * listMaintenance;
...
After Synchronising I can then set a number of parameters like rowHeight, numberOfRowsInSection:

But I am not sure how to access each tables cell’s properties. With a single table one would use:

Code:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	static NSString *CellIdentifier = @”Cell”;
}
and all the other various methods associated with the cell.

So, how is this best done??

Pete
Attached Thumbnails
Click image for larger version

Name:	TableView-1.png
Views:	60
Size:	37.0 KB
ID:	347067  
Fritzables is offline   0 Reply With Quote
Old Jul 8, 2012, 02:52 AM   #2
CodeBreaker
macrumors 6502
 
Join Date: Nov 2010
Location: Sea of Tranquility
This is trivial, as you have references to both your tables. In the delegate methods of your tables, you just have to check which table called it, and return appropriate data.

Something like this:

Code:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([tableView isEqual:self.listVehicle]) {
        static NSString *ListVehicleCellIdentifier = @"ListVehicleCellIdentifier";
        //do the usual cell deque/alloc/configure stuff here, and return the cell
        
    } else if ([tableView isEqual:self.listMaintenance]) {
        static NSString *ListMaintenanceCellIdentifier = @"ListMaintenanceCellIdentifier";
        //do the usual cell deque/alloc/configure stuff here, and return the cell
    } else {
        NSLog(@"I have no idea what's going on...");
        return nil;
    }
}
__________________
.
CodeBreaker is offline   0 Reply With Quote
Old Jul 8, 2012, 07:25 PM   #3
Fritzables
Thread Starter
macrumors regular
 
Join Date: May 2011
Location: Brisbane AUSTRALIA
Thanks CodeBreaker..... looks like the trick.

Thanks again.

Pete
Fritzables is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:10 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC