SceneDetailViewController.swift 3.12 KB
//
//  SceneDetailViewController.swift
//  ParentAssistant
//
//  Created by Cao yang on 2018/3/22.
//  Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
//

import UIKit

class SceneDetailViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {
    
    lazy var sceneTableView = {()->UITableView in
        let table = UITableView.init(frame: self.view.bounds)
        table.backgroundColor = backGroundColor
        table.delegate = self
        table.dataSource = self
        table.separatorStyle = UITableViewCellSeparatorStyle.none
        table.register(UINib.init(nibName: "SceneTopCell", bundle: nil), forCellReuseIdentifier: "cultureCell")
        table.register(UINib.init(nibName: "SceneMiddleCell", bundle: nil), forCellReuseIdentifier: "scoreCell")
        table.register(UINib.init(nibName: "SceneDownCell", bundle: nil), forCellReuseIdentifier: "disciplineCell")
        
        return table
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "场景详情"
        self.view.backgroundColor = backGroundColor
        self.view.addSubview(self.sceneTableView)
        sceneTableView.snp.makeConstraints { (maker) in
            maker.width.equalToSuperview()
            maker.bottom.equalToSuperview()
            maker.top.equalToSuperview()
            maker.centerX.equalToSuperview()
        }
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        return 3
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 2 {
            return 5
        }
        return 1
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

        switch indexPath.section {
        case 0:
            return 240
        case 1:
            return screenWidth*0.62
        case 2:
            return 70
        default:
            return 0
        }
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = UITableViewCell.init()
        switch indexPath.section {
        case 0:
            cell = tableView.dequeueReusableCell(withIdentifier: "cultureCell", for: indexPath) as! SceneTopCell
            return cell
        case 1:
            cell = tableView.dequeueReusableCell(withIdentifier: "scoreCell", for: indexPath) as! SceneMiddleCell
            return cell
        case 2:
            cell = tableView.dequeueReusableCell(withIdentifier: "disciplineCell", for: indexPath) as! SceneDownCell
            return cell
        default:
            return cell
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}