W iOS zaznaczona komórka powinna przejść do górnej części UITableView

Mam więcej niż 20 komórek w moim niestandardowym widoku tabeli, w czasie wykonywania będzie widocznych 6 komórek. Teraz wybieram czwartą komórkę oznacza, że ​​ta czwarta komórka musi wejść na pierwszą pozycję i piątą komórkę na 2. pozycji i tak dalej. jak to zrobić, próbowałem tak.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MACalendarCustomCell *cell = (MACalendarCustomCell*) [tableView dequeueReusableCellWithIdentifier:[MACalendarCustomCell reuseIdentifier]];
    if(cell == nil)
    {
        [[NSBundle mainBundle] loadNibNamed:@"MACalendarCustomCell" owner:self options:nil];
        cell = customCell;
        customCell = nil;

    }

        cell.lbl_CalendarTitle.text = [arr_CalendarTitle objectAtIndex:indexPath.row];
        cell.lbl_CalendarSubTitle.text = [arr_CalendarSubTitle objectAtIndex:indexPath.row];
        cell.lbl_calendarEventTime.text = [arr_CalendarEventTime objectAtIndex:indexPath.row];
        cell.lbl_calendarDate.text = [arr_CalendarDate objectAtIndex:indexPath.row];
        cell.lbl_CalendarMonth.text = [arr_CalendarMonth objectAtIndex:indexPath.row];
        cell.lbl_CalendarYear.text = [arr_CalendarYear objectAtIndex:indexPath.row];
        cell.img_BackGround.image = [UIImage imageNamed:@"calendar_Cell_Up.png"];

        //here click event is occurred.
        cell.btn_CollapseExpand.tag = indexPath.row;
        [cell.btn_CollapseExpand addTarget:self action:@selector(method_Expand:) forControlEvents:UIControlEventTouchUpInside];
    return cell;

}

Wywołania zdarzeń ButtonPressed

- (void)method_Expand:(UIButton*)sender
{
    UITableViewCell *cell = (UITableViewCell *)sender.superview;
    NSIndexPath *indexpath = [tbl_CalendarList indexPathForCell:cell];

    [tbl_CalendarList moveRowAtIndexPath:[NSIndexPath indexPathForItem:indexpath.row inSection:indexpath.section] toIndexPath:[NSIndexPath indexPathForItem:0 inSection:indexpath.section]];

    int_SelectedIndex = sender.tag;
    NSLog(@"Selected Button : %ld",(long)int_SelectedIndex);
    if ( int_TempSelectedIndex != int_SelectedIndex)
    {
        int_TempSelectedIndex = int_SelectedIndex;
    }
    else
    {
        int_TempSelectedIndex = -1;
    }

    [tbl_CalendarList reloadData];
}

Zmiana rozmiaru komórki

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (indexPath.row == int_TempSelectedIndex )
    {
        cellSize = 300;
        isRowSelected[indexPath.row] = YES;
    }
    else
    {
        cellSize = 100;
        isRowSelected[indexPath.row] = NO;
    }

    return cellSize;

}

Teraz mam to w symulatorze.

kiedy nacisnąłem, przychodzi tak.

Ta wybrana komórka powinna dotrzeć do pierwszej pozycji.

questionAnswers(4)

yourAnswerToTheQuestion