Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableview Reusability issue when drawing a line on tableview cell and moving it to the end of the table
    primarykey
    data
    text
    <p>I have to make an application where I can add N number of rows in UITableview.This is how I am using <strong>reusability</strong>.</p> <pre><code>-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"MyCell"; UITableViewCell *Cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(Cell==nil) { Cell=[self tableViewCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath ofTableView:tableView]; } [Cell setSelectionStyle:UITableViewCellEditingStyleNone]; [Cell setAccessoryType:UITableViewCellAccessoryNone]; [self ConfigureCell:Cell forIndexPath:indexPath forTableView:tableView]; return Cell; } </code></pre> <p>Then on <strong>swipe right</strong> I have to <strong>draw a line and add button</strong> on a particular cell of UITableview that I am doing in swipe gesture method after retrieving the UITableviewCell in that method and have to move cell to the bottom after adding the subviews.</p> <pre><code>CGPoint location = [recognizer locationInView:GroupedTableView]; NSIndexPath *IndexPath = [GroupedTableView indexPathForRowAtPoint:location]; UITableViewCell *cell = [self.GroupedTableView cellForRowAtIndexPath:IndexPath]; UIButton *CrossButton=[UIButton buttonWithType:UIButtonTypeRoundedRect]; CrossButton.frame=CGRectMake(250, 12, 15, 15); [CrossButton setBackgroundImage:[UIImage imageNamed:@"x.png"] forState:UIControlStateNormal]; CrossButton.tag=800+IndexPath.row; [CrossButton addTarget:self action:@selector(CrossButtonAction:) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:CrossButton]; UIImageView *LineImage=[[UIImageView alloc]init]; LineImage.frame=CGRectMake(10, 19, 220, 2); LineImage.tag=700+IndexPath.row; LineImage.image=[UIImage imageNamed:@"line.png"]; LineImage.userInteractionEnabled=YES; [cell.contentView addSubview:LineImage]; NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:RowNum inSection:0]; [self.GroupTableContentArray insertObject:[self.GroupTableContentArray objectAtIndex:IndexPath.row] atIndex:lastIndexPath.row+1]; [self.GroupTableContentArray removeObjectAtIndex:IndexPath.row]; [self.GroupedTableView moveRowAtIndexPath:IndexPath toIndexPath:lastIndexPath]; </code></pre> <p>This also works fine till the table height is small but once it is bigger than the screen size and I scroll to see the bottom content,the line I have drawn on that particular cell vanishes and sometimes its visible on other cell which was not marked.I know this is the issue of reusability but I am unable to figure out a way.</p> <p>My requirement is like any.Do app where we swipe right to select a finished task and put it at the bottom of the table.Any help would be highly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload