[Swift实战]豆瓣电台

标题界面布局



这节的内容主要是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)

下一节内容,我们将一起来学习一下怎么获取网络数据以及json的解析转化。



上一课时: 下一课时:

相关课程

课时简介

课时发布人:admin

发布于:2015-01-08

359 0

课程创建人

最近最近学完的人( 全部1人 )

最近收藏该课时的人( 全部1人 )

立即注册
学习路上要有伙伴同行!
登录后可与26名学员及知识达人交流、学习。