-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewsViewController.swift
More file actions
70 lines (48 loc) · 2.15 KB
/
NewsViewController.swift
File metadata and controls
70 lines (48 loc) · 2.15 KB
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
65
66
67
68
69
70
//
// NewsViewController.swift
// Walkthroughs
//
// Created by Buty on 8/17/16.
// Copyright © 2016 Developers Academy. All rights reserved.
//
import UIKit
import SafariServices
class NewsViewController: UITableViewController
{
var courses: [News]!
// MARK: - View Controller Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
let course1 = News(title: "Master the Swift ", date: "Everything you need to learn about Swift to get up and running with iOS Development", image: UIImage(named: "19")!, content: "http://www.developersacademy.io/4courses")
let course15 = News(title: "Build Snapchat", date: "Create self-destructive photo and video messaging app like Snapchat. Learn Parse, Instant Messaging and Push Notification", image: UIImage(named: "15")!, content: "http://www.developersacademy.io/")
courses = [course1, course15]
// Make the row height dynamic
tableView.estimatedRowHeight = tableView.rowHeight
tableView.rowHeight = UITableViewAutomaticDimension
}
// MARK: - UITableViewDataSource
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return courses.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("Course Cell", forIndexPath: indexPath) as! CourseTableViewCell
cell.course = courses[indexPath.row]
return cell
}
// MARK: - UITableViewDelegate
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
}
// MARK: - Show Webpage with SFSafariViewController
}
extension NewsViewController : SFSafariViewControllerDelegate
{
func safariViewControllerDidFinish(controller: SFSafariViewController)
{
controller.dismissViewControllerAnimated(true, completion: nil)
}
}