我在分组动态表视图方面苦苦挣扎。我想要2组。基本上,在第一组我希望拥有客户数据和第二组订单。第一组将始终具有相同的行数。什么是我的问题 - 我想将文本字段放入第一部分的每一行(使用不同的占位符),但是当我运行应用程序时,textfield只在最后一行。有谁知道我做错了什么?谢谢
声明我的属性
[
{
"attributes": {
"id": "Step1"
},
"height": 42,
"html": "This is ready to complete",
"nodeName": "span",
"tag": "<span id=\"Step1\">This is ready to complete</span>",
"text": "This is ready to complete,
"visible": true, // this can also be false this is what i want to fetch and monitor whether true or fals
"width": 229,
"x": 624,
"y": 484
}
]
TableViewController.swift:
var textField = UITextField()
var udaje = ["Jméno zákazníka","Kontaktní osoba","Telefon","Email","Fakturační adresa","Dodací adresa","IČO/DIČ"]
答案 0 :(得分:1)
尝试这种代码:
你的问题是使用self.textField。不是self.textField使用cell.textField。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = UITableViewCell()
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCellWithIdentifier("udajeCell", forIndexPath: indexPath) as! UITableViewCell
cell.textField.frame = cell.contentView.frame
cell.textField.placeholder = self.udaje[indexPath.row]
cell.contentView.addSubview(textField)
} else if (indexPath.section == 1) {
let cell = tableView.dequeueReusableCellWithIdentifier("pilyCell", forIndexPath: indexPath) as! UITableViewCell
cell.textLabel?.text = "Přidat pilu"
cell.detailTextLabel?.text = "+"
}
return cell
}