Reputation:
in my app there are a custom cell which have a button with some action as well as i must perfrom didSelectRowAtIndexPath method my button action doesn't perform beacuse of didSelectRowAtIndexPath method.
My code is given below->
-(void)tableView:(UITableView *)tableView willDisplayCell:(DriverListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.fromLbl.text=[[jobArray objectAtIndex:indexPath.row]objectForKey:@"pickup_addr"];
cell.toLbl.text=[[jobArray objectAtIndex:indexPath.row]objectForKey:@"deliver_address"];
[cell.arrowBtn addTarget:self action:@selector(moreInfo:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)moreInfo:(UIButton*)sender
{
NSLog(@"more info Clicked");
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"whole row selected");
}
Can I perform both action simultaneously? Or give me some idea to solve problem.
I must have perform both action one on custom cell button click and other on whole row selection.
Upvotes: 1
Views: 1093
Reputation: 144
If button will be clicked -(void)moreInfo:(UIButton*)sender
this function will be called.
But if you select the cell didselectrowatindexpath
function will be called.
In order to perform both action simultaneously remove your uibutton and then call -(void)moreInfo:(int)index
function from didselectrowatindexpath
method, to perform both actions at the same time.
-(void)tableView:(UITableView *)tableView willDisplayCell:(DriverListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.fromLbl.text=[[jobArray objectAtIndex:indexPath.row]objectForKey:@"pickup_addr"];
cell.toLbl.text=[[jobArray objectAtIndex:indexPath.row]objectForKey:@"deliver_address"];
}
-(void)moreInfo:(int)index
{
NSLog(@"more info Clicked");
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self moreInfo:indexpath.row];
NSLog(@"whole row selected");
}
Upvotes: 1