Я пытаюсь использовать UITextField из TextFieldFloatingPlaceholder
cocoapods (https://github.com/taiking/TextFieldFloatingPlaceholder) внутри UITableViewCell
.
. Я добавил UITextField
внутри ячейки прототипа в раскадровке, изменил его класс на TextFieldFloatingPlaceholder
, и он прекрасно работает, когда я запускаю приложение.
НО, мне нужно программно установить его свойство-заполнитель, поэтому я создал @IBOutlet
для этого UITextField
, чтобыmy UITableViewCell
. К сожалению, он не распознает тип TextFieldFloatingPlaceholder. Xcode показывает ошибку Использование неопределенного типа TextFieldFloatingPlaceholder
.
Мне нужен именно этот пользовательский тип, поэтому в моем ViewController
я могуполучить доступ к свойству placeholder
- я также попытался привести UITextField
к TextFieldFloatingPlaceholder
, но безуспешно. Я пробовал некоторые другие модули, но все они выдали ту же ошибку.
Что я делаю не так?
FieldTableViewCell.swift
import UIKit
class FieldTableViewCell: UITableViewCell {
@IBOutlet var textField: TextFieldFloatingPlaceholder! //Use of undeclared type 'TextFieldFloatingPlaceholder'
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
}
}
UIViewController.swift (фрагмент)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "FieldTableViewCell") as? FieldTableViewCell else {return
UITableViewCell()}
cell.textField.placeholder = "My dynamic string" //ERROR
cell.selectionStyle = .none
return cell
}
}