2016-07-28 4 views
12

मैं निम्न त्रुटि हो रही हैस्विफ्ट 3 में CABasicAnimation प्रतिनिधि सेट करने की समस्या?

प्रकार 'StarButton' टाइप करने के लिए का मूल्य निर्दिष्ट नहीं किया जा सकता 'CAAnimationDelegate?'

इस CABasicAnimation ब्लॉक की अंतिम पंक्ति पर

:

let fillCircle = CABasicAnimation(keyPath: "opacity") 
fillCircle.toValue = 0 
fillCircle.duration = 0.3 
fillCircle.setValue(notFavoriteKey, forKey: starKey) 
fillCircle.delegate = self // this is where the error is thrown 

self एक कस्टम UIButton वर्ग है। स्विफ्ट के पिछले संस्करणों में यह कोई मुद्दा नहीं था ... समाधान पर कोई सुझाव?

https://www.dropbox.com/s/gvc2sky05f4p3au/StarButton.swift?dl=0

+0

क्या आप वाकई प्रतिनिधि प्रोटोकॉल के अनुरूप हैं? ऐप्पल डॉक्स से – Fogmeister

+0

'UIButton' (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/)' CAAnimationDelegate' के अनुरूप नहीं है। क्या आपने स्पष्ट रूप से कहा था कि आपका सबक्लास एक प्रतिनिधि था? Http://stackoverflow.com/questions/24024466/how-do-i-make-a-class-conform-to-a-delegate-in-swift – Doc

+0

@Fogmeister अच्छी तरह से यह एक ओपन सोर्स घटक का हिस्सा है जिसे मैंने पकड़ लिया और फ़ाइल की जांच करने के बाद इसमें कोई प्रोटोकॉल नहीं लगता है .. हालांकि यह तेजी से 2.xx –

उत्तर

10

ऊपर टिप्पणी में उल्लेख किया @Doc के रूप में, समाधान के लिए है:

अद्यतन

यहाँ एक डाउनलोड स्रोत फ़ाइल के लिए सबसे अच्छा संदर्भ के लिए StarButton वर्ग के लिए कड़ी है

class StarButton: UIButton { 

के साथ प्रतिस्थापित करें
class StarButton: UIButton, CAAnimationDelegate { 

ऐसा लगता है कि CAAnimationDelegate प्रोटोकॉल अब स्पष्ट नहीं है और इसे स्पष्ट रूप से निर्दिष्ट किया जाना चाहिए।

संबंधित मुद्दे