HI, I'm developing an app, in landscape mode, I need to sh开发者_StackOverflowow 3 tables in the same window, how to achieve this? as my view controller, I have for one table>
@interface ChoiceViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
NSMutableArray *array;
}
but how to connect in the xib the new tables? how to call the other delegate, datasources, Uitableview for creating the new tables?
thank you!
Add IBOutlets in your view controller's interface:
@interface ChoiceViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
UITableView *table1;
UITableView *table2;
UITableView *table3;
NSMutableArray *array;
}
@property(nonatomic,retain) IBOutlet UITableView *table1;
@property(nonatomic,retain) IBOutlet UITableView *table2;
@property(nonatomic,retain) IBOutlet UITableView *table3;
@end
Connect the outlets to the view controller in Interface Builder, optionally connect delegate/dataSource outlets of the table views back to the view controller. Then add the following to the implementation.
@implementation ChoiceViewController
@synthesize table1, table2, table3;
- (void) dealloc
{
self.table1 = nil;
self.table2 = nil;
self.table3 = nil;
// Most likely, [array release];
[super dealloc];
}
@end
In your UITableViewDelegate/UITableViewDataSource methods test which table view asks for data and return the appropriate data.
Alternatively, you can set up multiple data sources, each responsible for one table view, but that depends on the design of your app.
精彩评论