In iOS selected cell should move to top portion in UITableView

后端 未结 4 524
后悔当初
后悔当初 2020-12-20 07:05

I have more than 20 cells in my custom table view, in execution time 6 cells will be visible. Now i select the 4 th cell means, that 4th cell have to come in first position

4条回答
  •  粉色の甜心
    2020-12-20 07:52

    In the method_Expand method after fetching the selected row you have to remove the object at the selected index and insert the removed object at 0 index.

    Also you want to move the move next item to the second position

    For that you have to increment the selected index and check if that index is with in the array bounds then remove that item and add it to the index 1;

    - (void)method_Expand:(UIButton*)sender
    
        UITableViewCell *cell = (UITableViewCell *)sender.superview;
        NSIndexPath *indexpath = [tbl_CalendarList indexPathForCell:cell];
    
        int nextIndex=indexpath.row+1;
    
        // first remove the object
       NSString *str=[arr_CalendarTitle objectAtIndex];
       [arr_CalendarTitle removeObjectAtIndex:indexpath.row];
       [arr_CalendarTitle insertObject:str atIndex:0];
    
       //do the same to arr_CalendarEventTime,arr_CalendarDate,arr_CalendarMont etc
    
      if([arr_CalendarTitle count]-1

提交回复
热议问题