【问题标题】:Swift - Table View Scrolling past header understatus barSwift - 表格视图滚动过去标题状态栏
【发布时间】:2014-06-16 15:52:10
【问题描述】:

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

我上网查了一下,有人建议使用 Nav Controller 并在其中放置一个 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
}


}

【问题讨论】:

    标签: uitableview swift ios7-statusbar


    【解决方案1】:

    在控制器的 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
    

    【讨论】:

      猜你喜欢
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-16
      • 1970-01-01
      • 2018-12-26
      • 1970-01-01
      相关资源
      最近更新 更多