zoukankan      html  css  js  c++  java
  • Swift UITableView

    import UIKit
    
    var tableview = UITableView()
    let cellid = "cell"
    var tableData = NSMutableArray()
    
    let sizeView = UIScreen.main.bounds.size
    
    
    
    
    class TableviewViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            
            
            self.creatUI()
    
            // Do any additional setup after loading the view.
        }
    
        func creatUI()  {
        
            self.title = "TableView"
            self.view.backgroundColor = UIColor.white
                
            tableview.frame = CGRect(x: 0, y: 20, sizeView.width, height: sizeView.height-20)
            tableview.delegate = self
            tableview.dataSource = self
            self.view .addSubview(tableview)
            
            for i in 1...66 {
                
                
                tableData.add("siwft(i)")
                
            }
    
            
            tableview.reloadData()
            
        
        }
        
        func numberOfSections(in tableView: UITableView) -> Int {
            return 1
        }
        
        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return tableData.count
        }
        
        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            
            var cell = tableView.dequeueReusableCell(withIdentifier: cellid)
            
            if cell == nil {
                
                cell = UITableViewCell (style: UITableViewCellStyle.default, reuseIdentifier: cellid)
                cell?.selectionStyle = UITableViewCellSelectionStyle.none
            }
            
            cell!.tintColor = UIColor.red
            cell!.textLabel?.text = tableData[indexPath.row] as! String
            
            
            return cell!
            
        }
        
        func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
            self.present(CollectionViewController(), animated: true) {
                
            }
    
        }
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
        
    
    
    
    }
  • 相关阅读:
    postgreSQL 时间线
    Using CSV-Format Log Output
    Understanding postgresql.conf : log*
    UNDERSTANDING POSTGRESQL.CONF: CHECKPOINT_SEGMENTS, CHECKPOINT_TIMEOUT, CHECKPOINT_WARNING
    PgSQL · 追根究底 · WAL日志空间的意外增长
    caffe源码学习
    Git 常用命令学习
    Linux系统的目录结构
    NMS 原理 了解
    nvidia-smi 查看GPU信息字段解读
  • 原文地址:https://www.cnblogs.com/xujiahui/p/6945695.html
Copyright © 2011-2022 走看看