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.

        }

    }

  • 相关阅读:
    梦1
    ASP.Net Web Page深入探讨
    创建ASP.NET WEB自定义控件——例程3
    自定义有模板功能的控件
    .net中Web自定义控件编写注意事项
    一个javascript脚本网站
    今天
    Konami世界一代(1)
    使用随机数
    做了一个赋值的测试
  • 原文地址:https://www.cnblogs.com/Zsmile/p/4200863.html
Copyright © 2011-2022 走看看