zoukankan      html  css  js  c++  java
  • swfit-学习笔记(表UITableView的简单使用)

    /*使用与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.

        }

    }

  • 相关阅读:
    centos6搭建docker镜像私服
    CentOS6安装docker
    通过pyenv进行多版本python管理
    ( 转)性能测试--地铁模型分析
    LoadRunner基于HTML-based script和URL-based script方式录制的区别和各自的使用场景
    一道Oracle子查询小练习
    Oracle多表连接查询
    LoadRunner关联通用函数的学习
    Selenium2(WebDriver)总结(五)---元素操作进阶(常用类)
    selenium2(WebDriver) API
  • 原文地址:https://www.cnblogs.com/Zsmile/p/4200863.html
Copyright © 2011-2022 走看看