因为构建tableviewCell而出现奇怪的错误

时间:2015-08-26 13:23:05

标签: ios swift custom-cell

我仔细检查了故事板,我正确设置了单元格的类,这里是生成警告的代码

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    //self.table.registerClass(UITableViewCell.self, forCellReuseIdentifier: "swiper")
    var cell:SWTableViewCell = tableView.dequeueReusableCellWithIdentifier("swiper", forIndexPath: indexPath) as! SWTableViewCell
    //cell = SWTableViewCell()
    cell.delegate = self
    if (UIDevice.currentDevice().systemVersion.toInt() >= 7) {
        cell.layoutMargins = UIEdgeInsetsZero
    }
    //circ(cell.layer)

    cell.leftUtilityButtons = self.leftButtons() as [AnyObject]
    cell.rightUtilityButtons = self.rightButtons() as [AnyObject]
    /*
    //cell.setCellHeight = cell.frame.size.height*/
    println(indexPath.section)
    return cell
}

如果我对出列行进行注释并取消注释,则警告消失:cell = SWTableViewCell() 并且每次出现警告都会使单元格出列,警告是:

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x7cc50870 h=--& v=--& H:[UITableViewCellContentView:0x7cc50bc0(0)]>",
    "<NSLayoutConstraint:0x7cc477c0 SWUtilityButtonView:0x7cc53bb0.width <= UITableViewCellContentView:0x7cc50bc0.width - 90>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7cc477c0 SWUtilityButtonView:0x7cc53bb0.width <= UITableViewCellContentView:0x7cc50bc0.width - 90>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-08-26 15:08:06.259 swipeTableView[2978:78305] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x7cc50870 h=--& v=--& H:[UITableViewCellContentView:0x7cc50bc0(0)]>",
    "<NSLayoutConstraint:0x7bf92b90 SWUtilityButtonView:0x7cc536e0.width <= UITableViewCellContentView:0x7cc50bc0.width - 90>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7bf92b90 SWUtilityButtonView:0x7cc536e0.width <= UITableViewCellContentView:0x7cc50bc0.width - 90>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

0 个答案:

没有答案