|
|
#1 |
|
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;
...
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”;
}
So, how is this best done?? Pete |
|
|
|
0
|
|
|
#2 |
|
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;
}
}
__________________
. |
|
|
|
0
|
|
|
#3 |
|
Thanks CodeBreaker..... looks like the trick.
Thanks again. Pete |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 08:10 AM.






Linear Mode
