zoukankan      html  css  js  c++  java
  • swift-UITableView

    import UIKit
    
    class FirstVC: UIViewController,UITableViewDelegate,UITableViewDataSource {
    
        var tableView : UITableView?
        var items = ["武汉","上海","武汉","上海","武汉","上海","武汉","上海"]
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            initView()
            
            // Do any additional setup after loading the view.
        }
        
        
        func initView(){
            
            self.tableView = UITableView(frame:self.view.frame,style:UITableViewStyle.plain)
            self.tableView!.dataSource = self
            self.tableView!.delegate = self
            self.tableView!.register(FirstCell.classForCoder(), forCellReuseIdentifier: "cell")
            self.view.addSubview(self.tableView!)
            self.tableView?.tableFooterView = UIView()
        }
        
        
        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            
            
    //        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
            //        cell.textLabel!.text = self.items[indexPath.row]
            let cell:FirstCell! = tableView.dequeueReusableCell(withIdentifier: "cell") as! FirstCell!
            cell.titles.text = self.items[indexPath.row]
    
            
            //去除cell阴影
            cell.selectionStyle = UITableViewCellSelectionStyle.none
    
            return cell
        }
        
        
        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return self.items.count
        }
        func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
            return 60
        }
        func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
            
            print("点击cell的indexpath.row:(items[indexPath.row])")
            
            let detail = First_detail_VC()
            self.navigationController?.pushViewController(detail, animated: true)
            
        }
        
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
     
  • 相关阅读:
    cocos2d-x 纹理研究
    cocos2d-x 获取图片的某像素点的RGBA颜色
    cocos2d-x Menu、MenuItem
    cocos2d-x ScrollView、TableView
    cocos2d-x RenderTexture
    cocos2d-x NotificationCenter
    cocos2d-x ClippingNode
    cocos2d-x Animation
    JDK,JRE,JVM区别与联系(ZZ)
    SQL中join的用法
  • 原文地址:https://www.cnblogs.com/sayimba/p/6215131.html
Copyright © 2011-2022 走看看