[相關信息:Xcode7.2 ; Swift2.0]
先回顧一下效果圖
看起來還不錯的設計圖
接下來我們需要把第一頁列表頁做起來
添加Table View控件
為Table View添加Table View Cell (行)
在Table View Cell里面添加需要的控件
添加完之后我們運行下APP會發現,列表還是空的?那是因為Table View沒有綁定數據,而且數據也沒有,當然顯示出來的列表也會是空的。
好,那接下來我們要讓列表顯示出來
綁定Table View到View Controller,設置Table View Cell 的 identifier
同時顯示 SB*(Main.storyboard)* 和代碼窗口
選擇正確的類文件
按住control鍵拖動到代碼窗口
設定綁定的名稱,點擊添加完成綁定
Table View與代碼綁定成功圖
在ViewController.swift類里面實現Table View的兩個方法
// MARK: - Table view data source
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 5
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tbView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
return cell
}
最后我們運行APP看下效果 (Command+R)
運行APP的效果
嗯,效果實現成功了??????