I want to show two tableview
on a viewOne on the left to the right of a how to do it? Online
Reply:
Why not?
I'll give you an idea.
1 Create a View-based Application, such as test
2 In the Open testViewController.xib
3 Put the two tableview in view, one on the left, one on the right, just drag the mouse to change the size and position.
Of course, you can use the code to create two uitableview, then added to the view, specify the location and size of the used codes.
In fact, I think your question is how to specify the data source and the agent for the two tableview in a viewcontroller.
Here is the answer.
4 Modify the code in testViewController.h follows:
@ Interface testViewController: UIViewController
@ Public
int testiv;
UITableView * tab1;
UITableView * tab2;
}
@ Property (nonatomic, retain) IBOutlet UITableView * tab1;
@ Property (nonatomic, retain) IBOutlet UITableView * tab2;
5 change in the code
in testViewController.m# Pragma mark -
# Pragma mark Table view data source
/ / Customize the number of sections in the table view.
- (NSInteger) numberOfSectionsInTableView: (UITableView *) tableView {
if (tableView == tab1)
return 1;
else {
return 2;
}
}
/ / Customize the number of rows in the table view.
- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section {
if (tableView == tab1)
return 1;
else {
return 2;
}
}
/ / Customize the appearance of table view cells.
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {
static NSString * CellIdentifier = @ "Cell";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier] autorelease];
if (tableView == tab1)
cell.textLabel.text = @ "111";
else {
cell.textLabel.text = @ "222";
}
}
/ / Configure the cell.
return cell;
}
Reply:
Yes, you need to open again xib file, do some connections, that is, two tableview's datasource, delegate, reference
Reply:
Reply:
Thank you, I learned
However, no click event
tableviewAfter I finished it found. . Only Navigation View
I want to achieve is tableview can click on the left side and can jump
Reply:
Reply:
Click on an event in another function, you can follow the examples above do it yourself.
Reply:
I also wrote two tableview, but the number of rows in my two tableview cell is the same, how this ended up not the same, who pass the best example, because some people say that the method does not work, the best tried his own way to tell me
Reply:
Better to rewrite its own tableview sdk has many examples
Reply:
Reply:
Simply write two viewcontroller it should also be placed inside a unified controller, similar to the ipad inside splitviewcontroller
Reply:
A floor that is entirely possible, I almost did just that!
Reply:
According to a floor that can set the left side of the TAG value is 0, 1, when the click event occurs, to determine what the value, and then distributed to the right of different events, not on the list? 1st floor completely, but he is Xib file to do, I had to write all the code, I believe, first floor entirely.
No comments:
Post a Comment