में मैं UITableViewController
पर स्विफ्ट 2 में accessoryButtonTappedForRowWithIndexPath:
को लागू करने का प्रयास कर रहा हूं।सहायक को कार्यान्वित करनाबटनटैप्डफॉररोविथ इंडेक्सपैथ: स्विफ्ट 2
जैसा कि मैंने नीचे बताया है, मुझे लगता है कि जब मैं disclosureIndicator
बनाता हूं, तो मुझे कुछ याद आ रहा है, लेकिन मुझे नहीं पता कि क्या। यह कोड से खींचा जाता है, लेकिन मेरी लक्षित कार्रवाई नहीं कहा जाता है। छी!
इस प्रोग्रामेटिक रूप से करने के लिए, मेरी समझ है कि मुझे वापस आने से पहले cellForRowAtIndexPath
में विवरण प्रकटीकरण सूचकांक जोड़ने की आवश्यकता है। मुझे लगता है कि इस प्रकार कर रहा हूँ:
// Create disclosure indicator button in the cell
let disclosureIndicatorButton = UIButton(type: UIButtonType.DetailDisclosure)
disclosureIndicatorButton.addTarget(self, action: "disclosureIndicatorPressed:event:", forControlEvents: UIControlEvents.TouchUpInside)
customCell.accessoryType = .DisclosureIndicator
मेरे कोड में, detailDisclosure शेवरॉन तैयार हो जाता है, लेकिन लक्ष्य कार्रवाई विधि मैं इसे करने के लिए सौंपा बुलाया प्राप्त करता है।
func disclosureIndicatorPressed(sender: UIButton, event: UIControlEvents) {
print("disclosure button pressed")
// convert touches to CGPoint, then determine indexPath
// if indexPath != nil, then call accessoryButtonTappedForRowWithIndexPath
}
अंत में accessoryButtonTappedForRowWithIndexPath
segue, जो मैं कर सकते हैं प्रदर्शन करने के लिए कोड में शामिल हैं:
तब मैं बटन के लिए कोई हैंडलर बनाने के लिए जब यह दबाया है की जरूरत है। मैं क्या खो रहा हूँ?
यह मेरी समस्या थी। 'प्रकटीकरण इंडिकेटर' सिर्फ आंख कैंडी है, खींचा जाने के अलावा कुछ और नहीं करता है। 'DetailDisclosureButton' वास्तव में इसके साथ जुड़ी कार्रवाई कर सकती है। मुझे स्क्वायर दूर करने के लिए धन्यवाद। – Adrian
खुशी हुई यह मदद की! चीयर्स :)! – Abhinav