Hi I've 2 UITableviews
(tableview1 and tableview2) in a UIViewController
. I already loaded some arrays to tableview1 by using MVC method but kept tableview2 as empty. Anyway I need to load selected rows from tableview1 to tableview2 by tapping the add button according to the below UI or drag tableview1 selected cells to tableview2 by using UILongpressgesture
.
Can Anyone give me the links to a related iOS (objective-c
) tutorial, instructions or a sample project repository to get some ideas.
This is how I loaded Data to the TableView1
- (void)viewDidLoad {
[super viewDidLoad];
tableView1.dataSource =self;
tableView2.delegate=self;
tableView2.dataSource=self;
tableView2.delegate=self;
self.cellSelected=[NSMutableArray array];
//Personal Assigned Array
SAassigned *psaUser1=[SAassigned new];
psaUser1.psaName=@"Peter Parker";
psaUser1.psaimage=@"men1.jpg";
SAassigned *psaUser2=[SAassigned new];
psaUser2.psaName=@"Michel Jordan";
psaUser2.psaimage=@"men2.jpg";
SAassigned *psaUser3=[SAassigned new];
psaUser3.psaName=@"Tiego Costa";
psaUser3.psaimage=@"men3.jpg";
SAassigned *psaUser4=[SAassigned new];
psaUser4.psaName=@"Ketty perry";
psaUser4.psaimage=@"women1.jpg";
SAassigned *psaUser5=[SAassigned new];
psaUser5.psaName=@"Jimmy More";
psaUser5.psaimage=@"men1.jpg";
SAassigned *psaUser6=[SAassigned new];
psaUser6.psaName=@"James Franklin";
psaUser6.psaimage=@"men2.jpg";
SAassigned *psaUser7=[SAassigned new];
psaUser7.psaName=@"Peter Parker";
psaUser7.psaimage=@"men3.jpg";
SAassigned *psaUser8=[SAassigned new];
psaUser8.psaName=@"Jessica Helan";
psaUser8.psaimage=@"women1.jpg";
assignedUsers=[NSMutableArray arrayWithObjects:psaUser1,psaUser2,psaUser3,psaUser4,psaUser5,psaUser6,psaUser7,psaUser8, nil];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//tableView 1
PACell *cell=[tableView dequeueReusableCellWithIdentifier:@"pCell"];
if([self.cellSelected containsObject:indexPath])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType=UITableViewCellAccessoryNone;
}
if (cell==nil) {
cell=[[PACell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pCell"];
}
//tableview 2
PSCell *cell2=[tableView dequeueReusableCellWithIdentifier:@"pCell2"];
if([self.cellSelected containsObject:indexPath])
{
cell2.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell2.accessoryType=UITableViewCellAccessoryNone;
}
if (cell2==nil) {
cell2=[[PSCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pCell2"];
}
SAassigned *assigned=nil;
if(tableView == self.tableView1)
{
assigned=[assignedUsers objectAtIndex:indexPath.row];
cell.persName.text=assigned.psaName;
cell.persImage.image=[UIImage imageNamed:assigned.psaimage];
}
else if(tableView == self.tableView2)
{
// not yet implemented / loaded - empty
return cell2;
}
return cell;
}
Add the selected row data into a separate array each time user clicks/selects the cell. and while showing the selected data into another cell, load them using that array.