1
我需要保持我的第一個單元格始終位於tableview頂部,當我移動其他cell.I花了很多時間和許多方法按鈕,我還沒有弄清楚如何解決這個問題。 這是我的代碼:自定義移動tableview單元格:如何始終保持第一個單元格在UITableView頂部時「moveRowAtIndexPath」
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//...do something to custom first cell design from xib file
//...do some thing to custom normal cells(cells at below of first cell)
[firstcell setEditing:NO animated:YES];
firstcell.userInteractionEnabled=NO;
if (indexPath.row==0)
{
return firstcell;
}
else
{
return cell;
}
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) // Don't move the first row
return NO;
return YES;
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
// i just change datasource for tableview at here
}
而且還有我的tableview當我移動的細胞(正常細胞)。
我想保持第一個單元格(藍色單元格)始終處於頂部,而不是與其他單元格交互。