Skip to content

Wanted to show either a view or a button at a same location #28

Description

@ngkarwai

I have a tableviewcell configured with a view and a button sharing a corner but i would like is to either show 1.

My code is as below inside -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath isExpanded:(BOOL)isExpanded

UIView *ratingView = (UIView *)[cell viewWithTag:3000];
UIButton *button1 = (UIButton *)[cell viewWithTag:2100];
...
if([[key objectForKey:@"rating"] isEqualToString:@"unrated"]){
    [ratingView setHidden:YES];
}
else{     
    [ratingView setHidden:NO];
}
if(cell.tag == indexPath.row) {
    int tag = 20000 * (int)indexPath.row;
    button1.tag = tag + 1;
    if([[key objectForKey:@"rating"] isEqualToString:@"unrated"]){
        [button1 setHidden:NO];
        [button1 setTitle:@"RATE" forState:UIControlStateNormal];
        [button1 addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
    }
    else{
        [button1 setHidden:YES];
    }
}

the value inside my array for "rating"
4,6,unrated,unrated,unrated,unrated,unrated,unrated,unrated,unrated,unrated,unrated,unrated

upon first load finish, when i expand the first cell, both the view and button will show... but when expand from third item to fifth, the view is gone and left the button... my tableview is relatively small as it only cover half of the screen due to have other things in the main view. when the cell is expanded only 1 cell is visible. when i scroll to bottom and scroll back to up, the second cell become the way it should be. sometimes some cell having both view and button no show.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions