2016-10-07 110 views
0

我正在嘗試開發一個應用程序,使用條形圖通過使用iOS Charts。我剛剛成立cocoapods文件,進口Charts.framework和編譯了該項目,我得到了以下錯誤:iOS圖表編譯錯誤

/Users/i3t/Desktop/AppAdmin/eCardFidAdmin/Pods/Charts/Source/Charts/Utils/ChartPlatform.swift:111:30: Method does not override any method from its superclass

此錯誤是在這個函數中發生的事情:

public final override func touchesCancelled(touches: Set<NSUITouch>, withEvent event: NSUIEvent?) 
{ 
    self.nsuiTouchesCancelled(touches, withEvent: event) 
} 

我刪除重寫的語句和我得到了這個新的錯誤:

/Users/i3t/Desktop/AppAdmin/eCardFidAdmin/Pods/Charts/Source/Charts/Utils/ChartPlatform.swift:111:21: Method 'touchesCancelled(:withEvent:)' with Objective-C selector 'touchesCancelled:withEvent:' conflicts with method 'touchesCancelled(:withEvent:)' from superclass 'UIResponder' with the same Objective-C selector

有人知道我該如何解決這個問題?

+0

假設這是斯威夫特3簽名改爲'與事件:',而不是'withEvent事件:' – dan

+0

尚不能工作。奇怪的是,其他功能沒有問題,只是功能「touchesCancelled」 –

回答

0

你沒有繼承其正確 使用

import Charts 

你的類必須從ChartPlatform

子類

如果你繼承,否則只能替換它不會工作

+0

嗨,謝謝你的回覆。但我不明白。當你說「你的課堂」時,你在說什麼課?正如我所說,我沒有改變我的代碼中的任何東西,只是導入Chart.framework。你能解釋得更好嗎? –

0

我有同樣的問題,我修正了它改變參數觸摸:作爲一個可選的像其父功能。 (SWIFT 2.2)

public final override func touchesCancelled(touches: Set<NSUITouch>?, withEvent event: NSUIEvent?) 
    { 
     self.nsuiTouchesCancelled(touches, withEvent: event) 
    }