사용자 지정 UITableViewCell 및 데이터 소스가있는 UITableView가 있습니다. 내 tableviewdelegate 클래스는 이벤트에서 콜백에 등록되고 이벤트를 받으면 tableview에서 데이터를 다시로드합니다.
tableviewcell 데이터를 편집 한 후 콜백이 발생합니다. 그러나 콜백이 왔을 때 데이터를 다시로드하면 tableview가 맨 위로 스크롤됩니다. 현재 선택에 머물지 않습니다.
그래서 현재 선택된 셀을 캐시하고 scrollToRowAtIndexPath를 시도했습니다.
그러나 나는 충돌을 치고있다.
테이블 데이터가로드 된 후 해당 행으로 어떻게 스크롤 할 수 있습니까?
{
[m_tableView reloadData];
if(m_currentEditingCell != nullptr)
{
[m_tableView scrollToRowAtIndexPath:m_currentEditingCell atScrollPosition:UITableViewScrollPositionNone animated:YES];
}
}
다음 코드는 새로 고침 후 셀을 선택할 수 있습니다.
{[m_tableView reloadData]; dispatch_async (dispatch_get_main_queue (), ^ {NSIndexPath * indexPath = [NSIndexPath indexPathForRow : ([m_tableView numberOfRowsInSection : ([m_tableView numberOfSections] -1)]-1) inSection : ([m_tableView numberOfSections] -1)]; if (m_currentCell! = nullptr) [self selectCurrentCell : m_currentCell];
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다