私は、UITextFields、UILabel、およびUITextViewの2つを持つexpandable tableViewCellを持っています。 tableViewが展開されると、ラベルが消え、UITextFieldsとUITextViewが表示されます。どちらのUITextFieldsでもカーソルは表示されますが、UITextViewではカーソルが表示されません。色合いを変更しようとしましたが、何も表示されませんでしたが、テキストを選択すると、色合いが強調されて表示されます。私もフレームを変更しようとしましたが、うまくいきませんでした。また、フレーム以外のプロパティに変更を加えずに、通常のUITextViewとして設定することもできます。 textViewは、プログラムでUITableViewCellクラスを使用してセットアップされ、すべてが動作するように見えますが、カーソルです。ここでカーソルがUITextViewに表示されないiOS
は、私はUITextViewを設定する方法は次のとおりです。ここで
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! StudentTableViewCell
cell.infoView.frame = CGRect(x: 23, y: 207, width: cell.frame.width - 36, height: cell.frame.height - 155)
cell.infoView.delegate = self
cell.infoView.text = classes[indexPath.row].info
cell.infoView.layer.cornerRadius = 5
cell.infoView.layer.masksToBounds = true
cell.placeholderField.frame = CGRect(x: 32, y: 92, width: self.view.frame.width - 38, height: 45)
if cell.infoView.text!.replacingOccurrences(of: " ", with: "") == "" {
cell.placeholderField.placeholder = "Description"
} else {
cell.placeholderField.placeholder = ""
}
cell.placeholderField.backgroundColor = UIColor.clear
cell.nameField.frame = CGRect(x: 23, y: 3, width: cell.frame.width - 70, height: 44)
cell.nameField.text = classes[indexPath.row].name
cell.nameField.delegate = self
cell.nameField.layer.cornerRadius = 5
cell.nameField.layer.masksToBounds = true
cell.nameField.borderStyle = .roundedRect
cell.teacherField.frame = CGRect(x: 23, y: 50, width: cell.frame.width - 36, height: 44)
cell.teacherField.text = classes[indexPath.row].teacher.name
cell.teacherField.delegate = self
cell.teacherField.layer.cornerRadius = 5
cell.teacherField.layer.masksToBounds = true
cell.teacherField.borderStyle = .roundedRect
cell.editButton.frame = CGRect(x: self.view.frame.width - 60, y: 15, width: 70, height: 20)
cell.editButton.addTarget(self, action: #selector(self.editInfoView), for: .touchUpInside)
cell.editButton.setTitle(cell.editButton.title(for: .normal) ?? "Edit", for: .normal)
cell.contentView.addSubview(cell.nameField)
cell.contentView.addSubview(cell.teacherField)
cell.contentView.addSubview(cell.infoView)
cell.contentView.addSubview(cell.editButton)
cell.contentView.addSubview(cell.placeholderField)
cell.textLabel?.text = classes[indexPath.row].name
cell.detailTextLabel?.text = classes[indexPath.row].teacher.name
return cell
}
は、クラスの定義である:カーソルが表示されない理由
class StudentTableViewCell: UITableViewCell {
var infoView = UITextView()
var placeholderField = UITextField()
var nameField = UITextField()
var teacherField = UITextField()
var editButton = UIButton()
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
誰でも知っていますか?
ご協力いただきありがとうございます。 Photo from the side
カーソルの前のビューがplaceholderFieldで、カーソルがまだないので、カーソルがブロックされていない。ここで
は、カーソル選択とデバッグの階層からの写真ですplaceholderFieldの下にあるときに表示されます。
私のコードは申し訳ありません。私はそれらのプロパティが物事を変更していたかどうかを確認するために多くのコメントをして、私は誤ってその中にあることを意図した行を削除しました。私は今までのすべてのもので自分のコードを更新しました。また、実際にどのようにカーソルをDebug View Hierarchyに表示しているか2つの写真を追加しました。私はまた、カーソルの説明を印刷し、何らかの理由でアルファが0です。アルファを0から1に変更して見えるようにする方法はありますか?もう一度助けてくれてありがとう。私が他のことをプログラムするとき、その提案を心に留めておく。 –