【发布时间】:2017-12-23 17:42:26
【问题描述】:
我创建了一个带有文本字段的自定义 UITableViewCell,但我想使用单元格的图像视图,而不是在我的自定义单元格中插入一个。
这是我的代码:
import UIKit
class TextFieldTableViewCell: UITableViewCell, UITextFieldDelegate {
@IBOutlet weak var textField : UITextField!
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
}
}
这是xib
在视图控制器中:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell : TextFieldTableViewCell! = tableView.dequeueReusableCell(withIdentifier: "textFieldCell", for: indexPath) as! TextFieldTableViewCell
cell!.textField.text = "William Stevenson"
cell!.textField.tag = indexPath.row
cell!.imageView?.image = UIImage.init(icon: .FAUser, size: CGSize(width: 35, height: 35), textColor : UIColor.gray)
return cell
}
}
但文本字段位于图片下方
我尝试在我的自定义单元格中插入 imageView
但第一条分隔线的宽度不同
我该如何解决这个问题? 谢谢!
【问题讨论】:
-
你想要第一个分隔线吗?还是第二个?
-
喜欢第二个
-
请不要在标题后面附加 solved。而是考虑将答案标记为已接受。这将告诉其他人问题已经解决。谢谢。
标签: ios swift uitableview uiimageview uitextfield