मैंने एक कस्टम UITableViewCell
बनाया, और UITextView
इस प्रोटोटाइप सेल के अंदर रखा गया था। जब मैं इस टेक्स्ट व्यू पर क्लिक करता हूं, तो कीबोर्ड स्वचालित रूप से उछाल सकता है। हालांकि, अगर मैं कीबोर्ड को छिपाना चाहता हूं, तो मुझे Return
कुंजी पर क्लिक करना होगा। यह काफी सुविधाजनक नहीं है।UITextView एक UITableViewCell के अंदर, टेक्स्टव्यू के पहले रीस्पॉन्डर को इस्तीफा कैसे दें जब तालिका देखें स्क्रू?
यहां सवाल है। जब मैं तालिकादृश्य स्क्रॉल करता हूं तो कीबोर्ड को छिपाने के लिए मैं टेक्स्ट व्यू के firstResponder
को इस्तीफा कैसे दे सकता हूं।
cellForRowAtIndex
विधि नीचे है।
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = UITableViewCell()
if(indexPath.section == 0){
cell = self.tableView.dequeueReusableCellWithIdentifier("InputCell")!
let textView = cell.viewWithTag(102) as! UITextView
textView.editable = true
textView.keyboardType = UIKeyboardType.Default
textView.delegate = self
textView.targetForAction(#selector(FeedBackViewController.getTextViewInsideCell(_:)), withSender: textView)
}
if(indexPath.section == 1){
cell = self.tableView.dequeueReusableCellWithIdentifier("ConfirmButtonCell")!
let label = cell.textLabel
label?.text = "send"
label?.textAlignment = NSTextAlignment.Center
label?.textColor = UIColor.redColor()
}
return cell
}
यहां कुछ विधियां लागू की गई हैं।
func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool{
if(text == "\n"){
textView.resignFirstResponder()
return false
}
return true
}
और मुझे नहीं पता कि इस विधि को कैसे कार्यान्वित किया जाए।
func scrollViewWillBeginDragging(scrollView: UIScrollView) {
}
'स्वयं पर का चयन कर सकते है .view.endEditing (true) 'आपके' scrollViewWillBeginDragging' में नौकरी करेगा। – NSNoob