所以我有一個自定義tableview
,並在該tableview中我有一個按鈕,圖像和2個標籤。這些項目中的每一個都會使用php從mysql服務器獲取json數據。我將我的項目從Objective-C轉換爲Swift,這樣我得到了這個錯誤。這是我的項目中最重要的代碼之一,因爲用戶點擊按鈕後,它將數組移動到其他數組,這樣做會爲單元格提供一個特殊的行號,以便所有圖像,標籤和按鈕知道哪個是要顯示的。Swift Error convertPoint(CGPoint,到:UITableView)
我試過切換它,所以.convert()
但只是錯誤,所以我離開它是如何它原來。
爲按鈕
// Follow Button
@IBAction func followButtonClick(_ sender: Any) {
// Adding row to tag
var buttonPosition = (sender as AnyObject).convertPoint(CGPoint.zero, to: self.myTableView)
var indexPath = self.myTableView.indexPathForRow(at: buttonPosition)!
// Creating an action per tag
if indexPath != nil {
// Showing Status Labels
var cell = self.myTableView.cellForRow(atIndexPath: indexPath)!
cell.firstStatusLabel.isHidden = false
cell.secondStatusLabel.isHidden = false
// Change Follow to Following
(sender as AnyObject).setImage(UIImage(named: "follow.png")!, for: .normal)
cell.followButton.isHidden = true
cell.followedButton.isHidden = false
self.myTableView.beginUpdates()
// ----- Inserting Cell to Section 0 -----
followedArray.insert(testArray[indexPath.row], at: 0)
myTableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .fade)
// ----- Removing Cell from Section 1 -----
testArray.remove(at: indexPath.row)
var rowToRemove = indexPath.row
self.myTableView.deleteRows(at: [IndexPath(row: rowToRemove, section: 1)], with: true)
self.myTableView.endUpdates()
}
}
錯誤的代碼
錯誤與新代碼
圖片所以它更容易閱讀
我在做這件事時得到3個錯誤給代碼 – BroSimple
我在底部加了他們 – BroSimple
謝謝兄弟,一切都很完美 – BroSimple