鍍金池/ 問答/iOS  網(wǎng)絡安全/ TableView:UITableView的移動行的問題

TableView:UITableView的移動行的問題

在創(chuàng)建移動行的代碼時,
加粗的兩行報錯,根據(jù)教程中使用的確實是這個方法:

 func tableView(_ tableView: UITableView, moveRowAtsourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath){

代碼如下:

 //是否可編輯
    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        return true
    }
    
    //允許重新排序單元格,如果返回否則無法重新排序
    func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
        return true
    }
    
    //從行~到行
    func tableView(_ tableView: UITableView, moveRowAtsourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath){
        
        **let item = Array[sourceIndexPath.row]
        
        Array.remove(at: sourceIndexPath.row)**
        Array.insert(item, atIndex: destinationIndexPath.row)
    }
       
        func didReceiveMemoryWarning() {
    }

問朋友說是沒有sourceIndexPath這個值。

參考鏈接:How To Reorder/Rearrange Table View Cells In Xcode 8 (Swift 3)

回答
編輯回答
遲月

現(xiàn)在解決了,是因為自己該打空格的地方?jīng)]有打空格??墒屈c擊Edit依然沒有出現(xiàn)可以移動操作的右邊的按鈕。
猜想也許是數(shù)據(jù)源的問題。

2018年7月1日 20:19