您的位置:首页 > 产品设计 > UI/UE

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

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐