我想用一个uitextfield
TextFieldFloatingPlaceholder
椰子荚(
https://github.com/taiking/TextFieldFloatingPlaceholder
)在一个
UITableViewCell
。
我加了一个
UITextField
在故事板的原型单元中,将其类更改为
文本字段浮动占位符
当我运行这个应用程序时,它运行得很好。
但是,我需要以编程方式设置它的占位符属性,所以我创建了
@IBOutlet
为了这个
输入框
对我
uiTableViewCell
. 很遗憾,它无法识别textfieldfloatingplaceholder类型。xcode显示未定义类型的错误使用
文本字段浮动占位符
.
我需要它是这种自定义类型,所以,在我的
ViewController
我可以进入它
placeholder
财产-我也试过
输入框
到
文本字段浮动占位符
,但没有成功。我试过其他的豆荚,但最后都犯了同样的错误。
我做错什么了?
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
}
}