UITableView实现从plist获取数据
2014-09-08 06:21
218 查看
最好将SB右侧的UseAutoLayout 和 Use Size Classes取消,再选中。
@IBOutlet var table : UITableView
var listArray = NSArray()
//此处使用NSArray()
//从plist文件-路径获取字典
var listPath = NSBundle.mainBundle().pathForResource("list", ofType: "plist")
listArray = NSArray(contentsOfFile:listPath)
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
var kLabel = cell.viewWithTag(1) as UILabel
kLabel.text = listArray.objectAtIndex(indexPath.row) as String
return cell
}
@IBOutlet var table : UITableView
var listArray = NSArray()
//此处使用NSArray()
//从plist文件-路径获取字典
var listPath = NSBundle.mainBundle().pathForResource("list", ofType: "plist")
listArray = NSArray(contentsOfFile:listPath)
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
var kLabel = cell.viewWithTag(1) as UILabel
kLabel.text = listArray.objectAtIndex(indexPath.row) as String
return cell
}
相关文章推荐
- iPhone开发之UITableView的小试牛刀 利用MVC模式从plist文件读取数据并字典转模型的格式实现
- iOS中UITableView--(从plist读取数据到model,实现懒加载, TableView的数据加载)
- 解决方案实现在UITableView中显示数据
- 网络获取图片数据后 利用viewpager实现弹簧效果
- iOS开发UI篇—实现UItableview控件数据刷新
- UIday1002:UITableView 2 用UITableView实现通讯录cell简单的数据移动、删除、添加功能
- (5) iphone 开发 在表视图(UITableView) 中利用UISearchBar实现数据的搜索,视图的多功能化
- ios-day13-01(私人通讯录。控制器之间的数据传递、保存密码和自动登录的实现、普通对象的归档、UITableView的局部刷新和向左滑动删除功能等等)
- iOS开发UI篇—实现UItableview控件数据刷新
- iOS开发UI基础—22实现UItableview控件数据刷新
- sqlite + UITableView 实现iPhone大数据浏览
- UITableView实现下拉刷新添加数据功能
- UI基础第十四弹:实现UItableview控件Cell数据刷新
- 使用 UITableView 创建表格应用演练(2)——从plist文件加载并显示数据
- iOS开发UI篇—实现UItableview控件数据刷新
- UITableView_6-团购实例,刷新数据,代理实现,GCD方法使用
- UITableView实现下拉刷新添加数据功能
- IOS UITableView 实现LOL数据展示
- android ViewPager实现的轮播图广告自定义视图,网络获取图片和数据
- iphone开发之表格组件UITableView的使用(四) 通过加载plist文件展示单组数据