INTRODUCTION
Selection feature can be used for many reasons in mobile app like for showing user choice from many available choices in list or for expanding particular choice option or we can hide while tapping any particular cell from list. Like for example if you have a list of contacts in your UITableView then by selection feature you can put in delete or edit option that from all list of contacts which are going to selected should appear different so that user can memorize that which contacts are selected because selected contacts appears different from others.
OVERVIEW
UITableView is view that used to display list of different or similar view in vertical scrollable content view. You must know what are delegates and data source methods of UITableView and how to use them. For more details you can read all information regarding UITableView here https://developer.apple.com/documentation/uikit/uitableview.
If you know basics of UITableView like where and how to use it after that UITableViewCell comes in role. UITableViewCell class in which content of single section of uitableview and its representation is maintained.
This Class includes properties and methods for setting and managing cell content and background (including text, images, and custom views), managing the cell selection and highlight state, managing accessory views, and initiating the editing of the cell contents. For more details you can read all information regarding UITableViewCell here https://developer.apple.com/documentation/uikit/uitableview.
Selection Animation Process:
For selection of cell and maintaining animation between changing of two states from selection to deselection we will first write didSelectRowAtIndexPath delegate method.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// set the reverse of selected boolean
cell.selected = !cell.isSelected;
if ([cell isSelected]){
// do here for selected cell method
} else {
// do here for unselected cell method
}
}
Inshort simple you can handle your selection process by isSelected property of UITableViewCell. When defaultely value of this property is set to FALSE then when user taps it then we have to make it TRUE by assigning its reverse current value of isSelected.