By using the list of static cells, we can easily make the page layout. The following is a demonstration using a "Add Task page".
as follows:
implementation steps:1, drag a tableviewcontroller into the storyboard and create a corresponding class (Mytabelviewcontroller.swift) to bind. 2, select table, set content to static cells,sections set to 2 in the Properties panel
3, select 1th sections, set rows to 1, and drag a textfiled into the cell
4, select 2ndSections, set rows to 2 to two cells and drag them into the corresponding label and switch controls
5,mytabelviewcontroller.swift
123456789101112131415161718192021222324252627 |
class MyTableViewController
:
UITableViewController {
override func viewDidLoad() {
super
.viewDidLoad()
self
.title =
"添加任务"
//去除尾部多余的空行
self
.tableView.tableFooterView =
UIView
(frame:
CGRectZero
)
}
override func didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
override func numberOfSectionsInTableView(tableView:
UITableView
) ->
Int {
return 2
}
override func tableView(tableView:
UITableView
, numberOfRowsInSection section:
Int
) ->
Int {
if section == 0 {
return 1
}
else
{
return 2
}
} }
|
Swift-page layout with tableview static cells