mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Update Sample View Controller
This commit is contained in:
@@ -12,55 +12,40 @@
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
|
||||
class ViewController: UIViewController, ASTableViewDataSource, ASTableViewDelegate {
|
||||
final class ViewController: ASViewController, ASTableDataSource, ASTableDelegate {
|
||||
|
||||
var tableView: ASTableView
|
||||
var tableNode: ASTableNode {
|
||||
return node as! ASTableNode
|
||||
}
|
||||
|
||||
|
||||
// MARK: UIViewController.
|
||||
|
||||
override required init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
self.tableView = ASTableView()
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
self.tableView.asyncDataSource = self
|
||||
self.tableView.asyncDelegate = self
|
||||
init() {
|
||||
super.init(node: ASTableNode())
|
||||
tableNode.delegate = self
|
||||
tableNode.dataSource = self
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("storyboards are incompatible with truth and beauty")
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.view.addSubview(self.tableView)
|
||||
}
|
||||
|
||||
override func viewWillLayoutSubviews() {
|
||||
self.tableView.frame = self.view.bounds
|
||||
}
|
||||
|
||||
override func prefersStatusBarHidden() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
// MARK: ASTableView data source and delegate.
|
||||
|
||||
func tableView(tableView: ASTableView!, nodeForRowAtIndexPath indexPath: NSIndexPath!) -> ASCellNode! {
|
||||
let patter = NSString(format: "[%ld.%ld] says hello!", indexPath.section, indexPath.row)
|
||||
func tableView(tableView: ASTableView, nodeForRowAtIndexPath indexPath: NSIndexPath) -> ASCellNode {
|
||||
let node = ASTextCellNode()
|
||||
node.text = patter as String
|
||||
node.text = String(format: "[%ld.%ld] says hello!", indexPath.section, indexPath.row)
|
||||
|
||||
return node
|
||||
}
|
||||
|
||||
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
|
||||
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
|
||||
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return 20
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user