2009-11-25 19 views
5

मैं विशेष सेल पर क्लिक अक्षम करना चाहता हूं। मतलब है, जब हम विशेष सेल पर स्पर्श करते हैं तो मैं हाइलाइट रंग (चयन संकेत) नहीं दिखाना चाहता हूं? कोई मदद कृपया?UITableview पर चयन छुपाएं कैसे?

+0

क्षमा करें। मुझे समाधान मिला है .. [सेल सेट चयन चयन: UITableViewCellSelectionStyleNone]; –

उत्तर

15

या तो cell.selectionStyle = UITableViewCellSelectionStyleNone; का उपयोग करें या false पर लौटें या tableView:willSelectRowAtIndexPath प्रतिनिधि null पर वापस आएं।

+0

मैंने स्टोरीबोर्ड में शैली को किसी के लिए सेट नहीं किया है, लेकिन मेरी विभाजक लाइनें बेर्सक गईं। जाहिर है कि दस्तावेज़ीकरण को पढ़ने के कारण, निर्दिष्ट प्रतिनिधि विधि में शून्य वापस करने से समस्या हल हो गई ... मुझे कुछ समय बचाने के लिए धन्यवाद। –

0

स्विफ्ट:

आप एक कस्टम सेल उपयोग कर रहे हैं:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCell(withIdentifier: "CellIdentifierID") 
    cell.selectionStyle = .none 
    return cell 
} 
:

class YourCustomCell: UITableViewCell { 
    override func awakeFromNib() { 
     setup() 
    } 

    init() { 
     setup() 
    } 

    required init?(coder aDecoder: NSCoder) { 
     super.init(coder: aDecoder) 
    } 

    fileprivate func setup() { 
     self.selectionStyle = .none 
    } 
} 

आप एक कस्टम सेल का उपयोग नहीं कर रहे हैं

बोनस: यदि आप सेल चयन को छिपाना चाहते हैं और func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {...} पर कॉल नहीं करना चाहते हैं तो केवल cell.isUserInteractionEnabled = false सेट करें। हालांकि, यह एक अच्छा अभ्यास नहीं है।

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