add additional field example in the footer of addition cell

This commit is contained in:
Bob Sun 2017-02-21 01:06:03 +08:00
parent e40cadaec1
commit 2829e9145d
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 9 additions and 4 deletions

View file

@ -19,6 +19,8 @@ class EditPasswordTableViewController: PasswordEditorTableViewController {
[[.type: PasswordEditorCellType.textViewCell, .title: "additions", .content: password!.getAdditionsPlainText()]],
]
sectionHeaderTitles = ["name", "password", "additions"].map {$0.uppercased()}
sectionFooterTitles = ["", "", "It is recommended to use \"key: value\" format to store additional fields as follows:\n url: https://www.apple.com\n username: passforios@gmail.com."]
super.viewDidLoad()
}

View file

@ -21,6 +21,7 @@ class PasswordEditorTableViewController: UITableViewController {
[Dictionary<PasswordEditorCellKey, Any>]
]()
var sectionHeaderTitles = [String]()
var sectionFooterTitles = [String]()
override func viewDidLoad() {
super.viewDidLoad()
@ -33,6 +34,8 @@ class PasswordEditorTableViewController: UITableViewController {
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 48
tableView.allowsSelection = false
self.tableView.sectionFooterHeight = UITableViewAutomaticDimension;
self.tableView.estimatedSectionFooterHeight = 0;
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@ -57,10 +60,6 @@ class PasswordEditorTableViewController: UITableViewController {
return 44
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.1
}
override func numberOfSections(in tableView: UITableView) -> Int {
return tableData.count
}
@ -73,5 +72,9 @@ class PasswordEditorTableViewController: UITableViewController {
return sectionHeaderTitles[section]
}
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return sectionFooterTitles[section]
}
}