refactor LabelTableView(Cell)
This commit is contained in:
parent
67570256d0
commit
63a0ad8fe6
2 changed files with 18 additions and 2 deletions
|
|
@ -8,10 +8,24 @@
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
|
struct LabelTableViewCellData {
|
||||||
|
var title: String
|
||||||
|
var content: String
|
||||||
|
}
|
||||||
|
|
||||||
class LabelTableViewCell: UITableViewCell {
|
class LabelTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
@IBOutlet weak var contentLabel: UILabel!
|
@IBOutlet weak var contentLabel: UILabel!
|
||||||
@IBOutlet weak var titleLabel: UILabel!
|
@IBOutlet weak var titleLabel: UILabel!
|
||||||
|
|
||||||
|
|
||||||
|
var cellData: LabelTableViewCellData? {
|
||||||
|
didSet {
|
||||||
|
titleLabel.text = cellData?.title
|
||||||
|
contentLabel.text = cellData?.content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override var canBecomeFirstResponder: Bool {
|
override var canBecomeFirstResponder: Bool {
|
||||||
get {
|
get {
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,10 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell", for: indexPath) as! LabelTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell", for: indexPath) as! LabelTableViewCell
|
||||||
cell.titleLabel.text = tableData[indexPath.section].item[indexPath.row].title
|
|
||||||
cell.contentLabel.text = tableData[indexPath.section].item[indexPath.row].content
|
let titleData = tableData[indexPath.section].item[indexPath.row].title
|
||||||
|
let contentData = tableData[indexPath.section].item[indexPath.row].content
|
||||||
|
cell.cellData = LabelTableViewCellData(title: titleData, content: contentData)
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue