I have a UITableView which I am creating by using custom UITableViewCell. The tableview shows some data populated from an array. Now I am using 2 image to highlight/unhighlight based on selection. [By default when application opens I am showing the first row with highlighted image without any selection].
The UITableView header contains one delete button now if I press delete button first time it happens succesfully.
-(IBAction)delete{
[myArray removeObjectAtIndex:0];
[tableview reloadData];
}
Now as tableview get refreshed, all row contains unhighlighted image. Now as I select 3rd row and press header delete button how should I get the index number to be deleted.
I know about didSelectRowAtIndexPath but is there any way which I put in IBAction method to get the selected cell index number?
Just create an ivar or property that holds the value of the latest selection. In the didSelectRowAtIndexPath method, have this line:
where rowSelected is a property. Then in your IBAction for the button, you can access that property:
In the viewDidLoad method you should set the value of that property to 0 since you want the first row selected at start up.