मैं प्रत्येक कोशिका में textfields के साथ एक मेज दृश्य बनाना चाहते हैं,स्विफ्ट में टेक्स्टफील्ड के साथ UITableview कैसे बनाएं?
मैं एक तेज फ़ाइल में एक कस्टम वर्ग है:
import UIKit
public class TextInputTableViewCell: UITableViewCell{
@IBOutlet weak var textField: UITextField!
public func configure(#text: String?, placeholder: String) {
textField.text = text
textField.placeholder = placeholder
textField.accessibilityValue = text
textField.accessibilityLabel = placeholder
}
}
तब मेरे ViewController में मैं
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCellWithIdentifier("TextInputCell") as! TextInputTableViewCell
cell.configure(text: "", placeholder: "Enter some text!")
text = cell.textField.text
return cell
}
है कि अच्छी तरह से काम करता है:
लेकिन जब उपयोगकर्ता टेक्स्टफील्ड में टेक्स्ट दर्ज करता है और बटन दबाता है तो मैं प्रत्येक टेक्स्टफील्ड के तारों को सरणी में संग्रहीत करना चाहता हूं। मैं
text = cell.textField.text
println(text)
साथ की कोशिश की है लेकिन यह अगर यह खाली था
मैं कैसे यह काम कर सकते हैं की तरह कुछ भी प्रिंट?
का उपयोग कर पहले से ही http में जवाब मूल्यों को प्रदर्शित करने://stackoverflow.com/questions/7344247/fetching-values-from-textfield-in-a-custom-cell-iphone –