3

我正在尝试在 App 中编写一个检查,在用户在第一个视图上输入信息后,视图更改为会议的 tableView。目前我面临两个问题;第一个问题是单元格滚动过标题并在状态栏下方,我该如何解决这个问题?第二个问题是向下滚动会拉动标题,有没有办法改变它?

我在网上看了一点,有人建议使用导航控制器并在其中放置一个 UItable 视图。我试图避免 StoryBoard,所以我想知道如何使用代码来做到这一点。

到目前为止,这是我的代码

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
}


}
4

1 回答 1

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
于 2014-10-14T17:37:39.370 回答