Add UIView on top of UITableViewController in Swift

I am currently using the UITableViewController (PFQueryTableViewController), I would like to display a UIView at the top of the TableView.

Ideally, I would like to do this in a storyboard, so I can easily add extra shortcuts / buttons to it. However, I cannot understand how or if you can do this in a storyboard. Is it correct?

I tried this programmatically. First I created a variable at the top:

var filterLabelView:UIView = UIView()

Then I added the following to ViewDidLoad:

filterLabelView.frame = CGRect(x: self.view.frame.width/2, y: self.view.frame.height/2, width: self.view.frame.width, height: 40)
filterLabelView.center = CGPointMake(self.view.frame.size.width  / 2, self.view.frame.size.height / 2)
filterLabelView.backgroundColor = UIColor.redColor()
self.view.addSubview(filterLabelView) // See below

I also tried:

self.view.insertSubview(filterLabelView, aboveSubview: tableView)

This creates a red UIView, but it seems to be built into the tableview, as when I look up and down, the View moves with it.

What i want to create

, , , . , , :

enter image description here

, - UIViewController UITableView , , , .

- ?

+4
1

UIViewController, .

UITableView Storyboard. , , , , customView.top= tableView.bottom. .

, UIViewController dataSource , UITableView ( viewDidLoad()).

, , viewDidAppear(), UITableViewController - UIViewController tableView .

, : , . . view UITableViewController UITableView. . , UITableViewController - , , .

, , .

, VC Storyboard. , cellForRowAtIndexPath dataSource .

2:

Parse, . (!! , Parse.) Parse PFQueryTableView, , , , Objective-C:

https://www.parse.com/questions/pfquery-tableview-for-uiviewcontroller

enter image description here

+4

All Articles