在更新到Xcode 9.0之前,我使用Xcode 8.3.3来处理uitableviewcontroller。第一行显式大。升级到Xcode 9.0后,就会发生这种情况。即使我取消 automaticAdjustsScrollViewInsets,填充仍然在这里。哈斯有没有遇到过这个问题?怎么解决?
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)
}
答案 0 :(得分:0)
在viewdidLoad中写下以下行 -
self.automaticallyAdjustsScrollViewInsets = false;
并删除最后一行
self.edgesForExtendedLayout = UIRectEdge.init(rawValue: 0)
希望它有所帮助...