|
|
|
iOS - How to create more than one UITableView with cell action in single view controller. |
|
|
|
|
|
|
|
use uiviewcontroller
and create uitableview in uiviewcontroller
|
|
|
|
|
Date :
2013-08-09 11:09:43 |
By :
LindyFralin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thanks LindyFralin.
Now working perfect but I'm using this method
http://www.allappsdevelopers.com/TopicDetail.aspx?TopicID=b9c3f8dd-8bf6-4244-8e56-5cdbd7c62979
|
|
|
|
|
Date :
2013-08-09 11:28:54 |
By :
vishwa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-08-09 11:32:16 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my project some uiviewcontroller with uitableview about 6 - 7 tableview
i think if use tag for control uitableview. it hard to remember table tag
.h
@property (strong, nonatomic) IBOutlet UITableView *tableView1;
@property (strong, nonatomic) IBOutlet UITableView *tableView2;
@property (strong, nonatomic) IBOutlet UITableView *tableView3;
@property (strong, nonatomic) IBOutlet UITableView *tableView4;
@property (strong, nonatomic) IBOutlet UITableView *tableView5;
@property (strong, nonatomic) IBOutlet UITableView *tableView6;
.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView==tableView1){
}else if(tableView==tableView2){
}else .......
}
i think easy to control and remember
|
ประวัติการแก้ไข 2013-08-09 11:52:13
|
|
|
|
Date :
2013-08-09 11:50:43 |
By :
LindyFralin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Yes mr.lindyfralin i use that method only
Code (Objective-C)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(tableView == tableView1){
return displayObject.count;
}else if(tableView == tableView2){
return 5;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle : UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.opaque = NO;
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
}
if (tableView == tableView1) {
NSDictionary *tmpDict = [displayObject objectAtIndex:indexPath.row];
NSMutableString *text;
text = [NSString stringWithFormat:@"%@ %@"
,[tmpDict objectForKey:jobid]
,[tmpDict objectForKey:position]];
NSMutableString *detail;
detail = [NSString stringWithFormat:@" %@ ,%@ ,%@"
,[tmpDict objectForKey:city]
,[tmpDict objectForKey:state]
,[tmpDict objectForKey:rate]];
cell.textLabel.text = text;
cell.detailTextLabel.text= detail;
[cell.textLabel setFont:[UIFont fontWithName:@"Avenir Bold" size:14]];
cell.detailTextLabel.textColor = [UIColor darkGrayColor];
[cell.detailTextLabel setFont:[UIFont fontWithName:@"Avenir" size:15]];
CGRect frameBtn = CGRectMake(320.0 - 32.0, 5.0, 28.0, 28.0);
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(customActionPressed:) forControlEvents:UIControlEventTouchDown];
cell.accessoryView = button;
[button setImage:[UIImage imageNamed:@"submit_blue.png"] forState:UIControlStateNormal];
[button setTitle:@"Hello" forState:UIControlStateNormal];
[button setFrame:frameBtn];
[cell addSubview:button];
}
else if(tableView == tableView2){
NSDictionary *tmpDict = [displayObject objectAtIndex:indexPath.row];
NSMutableString *text;
text = [NSString stringWithFormat:@"%@ "
,[tmpDict objectForKey:position]
];
NSMutableString *detail;
detail = [NSString stringWithFormat:@" %@ "
,[tmpDict objectForKey:city]
];
cell.textLabel.text = text;
cell.detailTextLabel.text= detail;
[cell.textLabel setFont:[UIFont fontWithName:@"Avenir Bold" size:14]];
cell.detailTextLabel.textColor = [UIColor darkGrayColor];
[cell.detailTextLabel setFont:[UIFont fontWithName:@"Avenir" size:15]];
}
return cell;
}
|
|
|
|
|
Date :
2013-08-09 12:21:50 |
By :
vishwa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|