3

I'm trying to write a check in App, where after the user enters information on the first view the view changes to a tableView of meetings. Currently I'm facing two issues; the first issue is the cell scroll past the header and under the status bar, How do I fix this? the second issue is scrolling down pulls the header with it, is there a way to change this?

I looked online a bit, and some people suggested using a Nav Controller and putting a UItable view inside of it. I'm trying to avoid the StoryBoard so I'm wondering how do I do this using code.

Here is my code so far

class MeetingsViewController: UITableViewController, UITableViewDelegate, {

@IBOutlet var meetingsView : UITableView
var meetings = []

override func viewDidLoad() {
    super.viewDidLoad()



    title = "Meetings"
    ![enter image description here][1]tableView.registerClass(MeetingCell.self, forCellReuseIdentifier: "cell")
    let edgeInsets = UIEdgeInsetsMake(20, 0, 0, 0)
    self.tableView.contentInset = edgeInsets
    self.tableView.scrollIndicatorInsets = edgeInsets




}

override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {
    return 10
}

 override func tableView(tableView: UITableView!, titleForHeaderInSection section: Int) -> String!
{
        return "Meetings"
}




override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? {
    let cell = tableView!.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as MeetingCell

    if let path = indexPath {
        //let entry = news[path.row] as NSDictionary

            cell.text = "Meeting Name "

            cell.detailTextLabel.text = "Time "
    }

    return cell
}


}
Nocturnal336
  • 31
  • 1
  • 4

1 Answers1

2

Try this in your controller's init():

let height = UIApplication.sharedApplication().statusBarFrame.size.height
let insets = UIEdgeInsets(top: height, left: 0, bottom: 0, right: 0)
self.tableView.contentInset = insets
self.tableView.scrollIndicatorInsets = insets
Luis
  • 3,451
  • 1
  • 27
  • 41