Ios 当按下滑动删除按钮时,应用程序崩溃
当我使用UITableViewCellEditingStyle.Delete时,我的应用程序转到顶层代码文件并显示线程1:EXC\U BAD\U访问(code=EXC\U I386\u GPFLT) 我想当用户在uitableview行上向左滑动时,它会显示“删除”按钮,当用户按下该按钮时,该行应该被删除。 它有时工作正常,但很多时候会崩溃,但当我再次运行应用程序时,行被删除。这是我的密码:Ios 当按下滑动删除按钮时,应用程序崩溃,ios,swift,uitableview,Ios,Swift,Uitableview,当我使用UITableViewCellEditingStyle.Delete时,我的应用程序转到顶层代码文件并显示线程1:EXC\U BAD\U访问(code=EXC\U I386\u GPFLT) 我想当用户在uitableview行上向左滑动时,它会显示“删除”按钮,当用户按下该按钮时,该行应该被删除。 它有时工作正常,但很多时候会崩溃,但当我再次运行应用程序时,行被删除。这是我的密码: var doItList = [String]() var stared = false class
var doItList = [String]()
var stared = false
class ViewController: UIViewController, UITableViewDelegate {
@IBOutlet weak var staredBtn: UIButton!
@IBOutlet weak var addDoItField: UITextField!
@IBOutlet weak var doItTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
if NSUserDefaults.standardUserDefaults().objectForKey("doItList") != nil {
doItList = NSUserDefaults.standardUserDefaults().objectForKey("doItList") as [String]
}
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return doItList.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
cell.textLabel?.text = doItList[indexPath.row]
return cell
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
doItList.removeAtIndex(indexPath.row)
NSUserDefaults.standardUserDefaults().setObject(doItList, forKey: "doItList")
doItTableView.reloadData()
}
}
这就是错误所在
无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
(lldb)你可以发布你的完整碰撞报告吗?请查看此帖子:。看起来您的doItList是NSArray而不是NSMutableArray这不是错误日志…这只是自动布局约束警告。