oscarimonbox
8/5/2016 - 10:22 AM

Marcar apartado en el que se está

Marcar apartado en el que se está

1) Variables para guardar section y row en ApplicationModel.h
@property (nonatomic) NSInteger currentSection;
@property (nonatomic) NSInteger currentIndex;

2) en ApplicationModel.m se inicializan
        inst.currentSection=0;
        inst.currentIndex=-1;
        
3) En la clase del menú:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [ApplicationModel sharedInstance].currentSection = indexPath.section;
    [ApplicationModel sharedInstance].currentIndex = indexPath.row;
...
NOTA SI HAY SECTION Y PUEDE SER CLICABLE, ACTUALIZAR ESTO TAMBIEN EN LA RUTINA QUE RECOGE EL TAP



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if((indexPath.section == [ApplicationModel sharedInstance].currentSection) && (indexPath.row == [ApplicationModel sharedInstance].currentIndex)){
        
        [menuCell setBackgroundColor:UIColorFromRGB(COLOR_MENU_SELECTED_BACKGROUND)];
    }
    else{
        [menuCell setBackgroundColor:[UIColor clearColor]];
    }
...

SI LA SECCION ES CLICABLE:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
            
...
            
            if(section == [ApplicationModel sharedInstance].currentSection){
                h.vwBackground.backgroundColor = UIColorFromRGB(COLOR_MENU_SELECTED_BACKGROUND);
            }
...