0
私はDynamic Prototypeテーブルも持っていますが、静的なセルもいくつかあります。私はこれらの静的なセルの1つが単一のセルの中に2つのテキストフィールドを持つことを許可しようとしています。私はこれを行うと信じて、私は各テキストフィールドのタグを設定する必要があります。ダイナミックプロトタイプUITableView内の静的セルにタグを追加することはできますか? (Swift)
しかし、どのように(可能であれば)下の行にタグを割り当てるのかよく分かりません。
TableViewController:
case DiveMasterIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveMasterCell)
(cell as! DiveMasterTableViewCell).textField.placeholder = Strings.DiveMaster.localized // tag 1001
case DiveMasterIDIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveMasterCell)
(cell as! DiveMasterIDTableViewCell).textField.placeholder = Strings.DiveMasterID.localized // tag 1002
2 TableViewCells
class DiveMasterTableViewCell: UITableViewCell, UITextFieldDelegate
{
@IBOutlet var textField: UITextField!
override func awakeFromNib()
{
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool)
{
super.setSelected(selected, animated: animated)
}
func textFieldDidEndEditing(textField: UITextField)
{
(self.tableViewController as! DiveDetailsNew2TableVC).diveModel.name = textField.text!
}
二
class DiveMasterIDTableViewCell: UITableViewCell, UITextFieldDelegate
{
@IBOutlet var textField: UITextField!
override func awakeFromNib()
{
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool)
{
super.setSelected(selected, animated: animated)
}
func textFieldDidEndEditing(textField: UITextField)
{
(self.tableViewController as! DiveDetailsNew2TableVC).diveModel.name = textField.text!
}
上記のコードによれば、それぞれに1つのテキストフィールドを持つ2つの異なるセルがあります。どちらが2つのテキストフィールドを含むはずですか?また、異なるセルのbtwセル識別子も異なるはずです。 – iyuna
ああ、テキストフィールド名を連鎖させるだけで十分ですか?それを考えなかった。 –
OK、今は機内にいます。これが使用されているセルであるため、両方のテキストフィールドをDiveMasterTableViewCellに追加する必要があります。単一のセル内にある2つの異なるテキストフィールドの名前で、それらを区別します...正しい? –