In my application i am using UITableview. In that delegate method didselectrow if i done any operation cant happen just.
For example i have 3 rows in tableview
if i select 1 row (indexPath.row==0) nothing will happen
if again select 2 row (indexPath.row==1) now it is Logging in console indexPath.row ==0 which is previous value.
if again select 1 row then its logging its previous value indexPath.row=1.
Why this going like .
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomerInfoViewController *customer = [[EquipmentViewController alloc]initWithNibName:@"CustomerInfoViewController" bundle:nil];
EquipmentViewController *equpment = [[EquipmentViewController alloc]initWithNibName:@"EquipmentViewController" bundle:nil];
ContactsViewController *contacts = [[ContactsViewController alloc]initWithNibName:@"ContactsViewController" bundle:nil];
if(indexPath.row == 0)
{
NSLog(@"one %d",indexPath.row);
[detailsView addSubview:customer.view];
}
if(indexPath.row == 1)
{
NSLog(@"two %d",indexPath.row);
[detailsView addSubview:equpment.view];
}
if(indexPath.row == 2)
{
NSLog(@"three%d",indexPath.row);
[detailsView addSubview:contacts.view];
}
}
Please anyone help me.
Thanks in advance.
You've implemented didDeselectRowAtIndexPath
method, not didSelectRowAtIndexPath
as intended
Wrong method implementation as Vladimir said. use didSelectRowAtIndexPath
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With