-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewsViewController.swift
executable file
·64 lines (43 loc) · 1.93 KB
/
NewsViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// SecondViewController.swift
// IOScell
//
// Created by Hado on 2017/5/11.
// Copyright © 2017年 Hado. All rights reserved.
//
import UIKit
class NewsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource{
var tableview : UITableView!
var newsList: [newsList] = []
override func viewDidLoad() {
super.viewDidLoad()
self.title = "新闻"
let item1 = UIBarButtonItem(title: "Next", style: UIBarButtonItemStyle.plain, target: self, action: "tapBarButton")
let item2 = UIBarButtonItem(title: "Refresh", style: UIBarButtonItemStyle.plain, target: self, action: "tapBarButton")
self.navigationItem.rightBarButtonItems = [item1, item2]
self.tableview = UITableView(frame:self.view.frame, style: .grouped)
self.tableview.delegate = self
self.tableview.dataSource = self
self.tableview!.register(UITableViewCell.self, forCellReuseIdentifier: "newsCell")
self.view.addSubview(self.tableview!)
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return newsList.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell = tableview.dequeueReusableCell(withIdentifier: "newsList", for: indexPath)
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.
}
*/
}