xcode 9从视图控制器面板,故事板上拖动后,在uitableview上方添加了额外的填充

时间:2017-09-21 03:55:36

标签: ios swift xcode uitableview

在更新到Xcode 9.0之前,我使用Xcode 8.3.3来处理uitableviewcontroller。第一行显式大。升级到Xcode 9.0后,就会发生这种情况。即使我取消enter image description here automaticAdjustsScrollViewInsets,填充仍然在这里。哈斯有没有遇到过这个问题?怎么解决? enter image description here

enter image description here

override func viewDidLoad() {
    super.viewDidLoad()

    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    let btn1 = UIButton(type: .custom)
    btn1.setImage(UIImage(named: "add"), for: .normal)
    btn1.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
    btn1.addTarget(self, action: #selector(createStaff(sender:)), for: .touchUpInside)
    let item1 = UIBarButtonItem(customView: btn1)

    let btn2 = UIButton(type: .custom)
    btn2.setImage(UIImage(named: "back_arrow"), for: .normal)
    btn2.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
    btn2.addTarget(self, action: #selector(back(sender:)), for: .touchUpInside)

    let item2 = UIBarButtonItem(customView: btn2)

    self.navigationItem.setRightBarButton(item1, animated: true)
    self.navigationItem.setLeftBarButton(item2, animated: true)
    self.automaticallyAdjustsScrollViewInsets = false;


    self.edgesForExtendedLayout = UIRectEdge.init(rawValue: 0)

 }

I HAVE EVEN TICKED SAFE LAYOUT BUT TO NO AVAIL

1 个答案:

答案 0 :(得分:0)

在viewdidLoad中写下以下行 -

  self.automaticallyAdjustsScrollViewInsets = false;

并删除最后一行

self.edgesForExtendedLayout = UIRectEdge.init(rawValue: 0)

希望它有所帮助...