// // ThreeViewController.swift // OJASwiftKitDemo // // Created by luxiaoming on 2017/3/8. // Copyright © 2017年 luxiaoming. All rights reserved. // import UIKit import OJASwiftKit class TESTDataModel: NSObject { var heightForCell: CGFloat = 44 var didSelectCallback: ((IndexPath) -> Void)? var shouldAutoDeselectCell: Bool = true var title: String = "111" // var cellStyle: UITableViewCellStyle = .default } class ThreeViewController: OJSTableViewController { var dataArray = [TESTDataModel]() } // MARK: - Lifecycle extension ThreeViewController { override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self tableView.ojs_registerCell(class: OJSStaticCell.self) // tableView.ojs_register(nib: OJSStaticCell.classForCoder()) self.dataArray = [TESTDataModel(), TESTDataModel(), TESTDataModel(), TESTDataModel(),] } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } // MARK: - UITableViewDataSource extension ThreeViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.dataArray.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.ojs_dequeueReusableCell(withClass: OJSStaticCell.self) // let cell = tableView.dequeueReusableCell(withIdentifier: OJSStaticCell.ojs_reuseIdentifier) as! OJSStaticCell cell.textLabel?.text = "text" return cell } } // MARK: - UITableViewDelegate extension ThreeViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return self.dataArray[indexPath.row].heightForCell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let model = self.dataArray[indexPath.row] if model.shouldAutoDeselectCell { tableView.deselectRow(at: indexPath, animated: true) } if let callback = model.didSelectCallback { callback(indexPath) } } } //// MARK: - Rotation //extension ThreeViewController { // // open override var shouldAutorotate: Bool { // return true // } // // open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { // return .allButUpsideDown // } // // open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { // return .landscapeLeft // } //}