我正在尝试在iOS 11上使用新的navigationBar的大标题功能.
但是,在我添加以下行之后:
self.navigationController?.navigationBar.prefersLargeTitles = true
Run Code Online (Sandbox Code Playgroud)
我发现navigationBar背景颜色变为黑色.
所以我再次手动设置背景颜色:
self.navigationController?.setBackgroundColor(UIColor(hexString: 0xFF7E79))
Run Code Online (Sandbox Code Playgroud)
但是,我发现statusBar背景颜色没有改变:
通过以下代码设置statusBar的背景颜色后:
guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return
statusBar.backgroundColor = UIColor(hexString: 0xFF7E79)
Run Code Online (Sandbox Code Playgroud)
它在statusBar和navigationBar之间给出了一条丑陋的1px黑线:
那么设置navigationBar的背景颜色的正确方法是什么?
我已启用应用程序组并创建了一个名为“group.com.classData”的组

我的代码如下所示:
let plistPath3 = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.classData")
print(plistPath3) //returns "nil"
Run Code Online (Sandbox Code Playgroud)
它返回零。为什么会发生这种情况?
我的代码如下所示:
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
let IndexPaths = NSArray(array:[indexPath])
let plistPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
let path = plistPath.appending("/ClassA.plist")
self.listClasses.remove(at:indexPath.row)
self.listClasses?.write(toFile: path, atomically: false)
tableView.reloadData()
self.tableView.deleteRows(at: IndexPaths as! [IndexPath], with: .fade)
}
Run Code Online (Sandbox Code Playgroud)
我知道,如果不更新数据源中的数据,将会引起问题,因此在更新TableView中的数据之前,我添加了这两行。
self.listClasses.remove(at:indexPath.row)
self.listClasses?.write(toFile: path, atomically: false)
Run Code Online (Sandbox Code Playgroud)
但这仍然行不通。我仍然收到此错误
'无效的更新:第0节中无效的行数。更新(6)之后现有节中包含的行数必须等于更新(6)前该节中包含的行数,加上或减去从该部分插入或删除的行数(已插入0,已删除1),加上或减去移入或移出该部分的行数(0移入,0移出)。
有人知道为什么会这样吗?
下面是我的TableView代码
@IBAction func Edit(_ sender: Any) {
setEditing(true, animated: true)
}
func tableView(_ tableView:UITableView, numberOfRowsInSection selection:Int) -> Int {
return self.listClasses.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath:IndexPath) -> …Run Code Online (Sandbox Code Playgroud)