首页 > 其他 > 详细

swfit-学习笔记(表UITableView的简单使用)

时间:2015-01-04 14:58:22      阅读:260      评论:0      收藏:0      [点我收藏+]

/*使用与Object-C基本类似,只做简单地使用,创建表及其设置数据源和代理*/

import UIKit 

 

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

    var _tableView = UITableView()    //声明全局变量

    override func viewDidLoad() {

        super.viewDidLoad()

        _tableView.frame = CGRectMake(0, 60, 320, 400)

        _tableView.delegate = self

        _tableView.dataSource = self

        _tableView.separatorStyle = UITableViewCellSeparatorStyle.None  //分隔线

        self.view.addSubview(_tableView)

        

    }

    //设置行数

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int

    {

        return 6;

    }

    //设置每行显示

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

    {

        var cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")

   if !cell.isKindOfClass(UITableViewCell){

        //关于重用还没搞明白,不知道是不是应该这么判断

        }

        cell.accessoryType = UITableViewCellAccessoryType.DetailButton  //详细按钮

        cell.selectionStyle = UITableViewCellSelectionStyle.None    //是否能选中

        cell.textLabel?.text = "叼炸天!"

        return cell

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

}

swfit-学习笔记(表UITableView的简单使用)

原文:http://www.cnblogs.com/Zsmile/p/4200863.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!