-
Notifications
You must be signed in to change notification settings - Fork 0
/
newsfeed.swift
executable file
·120 lines (68 loc) · 3.46 KB
/
newsfeed.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// ViewController.swift
// DeepLifeApp
//
// Created by Aman on 7/26/16.
// Copyright © 2016 Aman. All rights reserved.
//
import UIKit
import CoreData
class newsfeed: UITableViewController
{
var List: Array<AnyObject> = []
// MARK: - View Controller Lifecycle
@IBOutlet weak var menubar: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
// self.tableView.rowHeight = 60
if revealViewController() != nil {
// revealViewController().rearViewRevealWidth = 62
menubar.target = revealViewController()
menubar.action = #selector(SWRevealViewController.revealToggle(_:))
revealViewController().rightViewRevealWidth = 150
menubar.target = revealViewController()
view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
// Make the row height dynamic
// tableView.estimatedRowHeight = tableView.rowHeight
self.tableView.rowHeight = 200
}
// MARK: - UITableViewDataSource
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return List.count
}
override func viewDidAppear(animated: Bool) {
let AppDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let Context: NSManagedObjectContext = AppDel.managedObjectContext
let request = NSFetchRequest(entityName: "Disciples")
List = try! Context.executeFetchRequest(request)
tableView.reloadData()
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell: NewsTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell") as! NewsTableViewCell
let data: NSManagedObject = List[indexPath.row] as! NSManagedObject
cell.title?.text = data.valueForKey("fullname") as? String
cell.newsContent?.text = data.valueForKey("email") as? String
// cell.newsImageView!.clipsToBounds = true
let image = data.valueForKey("image") as? NSData
cell.newsImageView!.image = UIImage(data: image!)
cell.newsImageView!.frame = CGRectMake(40, 60, 40, 40)
// cell.newsImageView!.image = data.valueForKey("image")! as? UIImage
cell.dateNews?.text = data.valueForKey("phonenumber") as? String
return cell
}
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.contentView.backgroundColor = UIColor.clearColor()
cell.layer.backgroundColor = CGColorCreate(CGColorSpaceCreateDeviceRGB(), [1.0, 1.0, 1.0, 1.0])
cell.layer.masksToBounds = false
cell.layer.cornerRadius = 3.0
cell.layer.shadowOffset = CGSizeMake(-1, 1)
cell.layer.shadowOpacity = 0.5
// cell.contentView.addSubview(whiteRoundedView)
// cell.contentView.sendSubviewToBack(whiteRoundedView)
}
}