觀看地址
http://v.youku.com/v_show/id_XNzMwMDg4NzAw.html
這節的內容主要是storyboard的操作。
有以下幾個知識點
1 TableView的DataSource與Delegate的設定。我們將其綁定在ViewController上,使之遵循UITableViewDataSource,UITableViewDelegate協議來實現。然后我們實現了兩個函數,一個返回了TableView中行數。也就是TableView里面有多少條數據。
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int{ return 10 }
一個返回了TableView的單元格(cell)實例,也就是單元格長什么樣
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{ let cell=UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "douban") return cell }
2 單元格的識別。
在storyboard中選中cell。然后設置ldentifier的值來實現。ldentifier的值與下列語句中的reuseIdentifier 的值(”douban”)對應。
let cell=UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "douban")
3 從頻道列表中返回主界面如果按照主界面跳轉到頻道列表的方式則會不斷地產生新的主界面。所以用dismissViewControllerAnimated函數來回跳
self.dismissViewControllerAnimated(true, completion: nil)
本節高清視頻及項目文件下載地址
http://pan.baidu.com/s/1sjHd5qX
下一節內容,我們將一起來學習一下怎么獲取網絡數據以及json的解析轉化。