1

I created a UITableView in Storyboard, added required Auto Layout constraints. I want to display an action sheet when a table cell is clicked, therefore I write the following codes:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: false)
    let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
    actionSheet.addAction(UIAlertAction(title: "Play Video",  style: .default, handler: { (action) -> Void in
        // Play Video
    }))

    actionSheet.addAction(UIAlertAction(title: "Share", style: .default, handler: { (action) -> Void in
        // Share
    }))

    actionSheet.addAction(UIAlertAction(title: "Delete", style: .destructive, handler: { (action) -> Void in
        // Delete
    }))

    actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
    self.present(actionSheet, animated: true, completion: nil)
}

Xcode doesn't complain about any auto layout issues (no warning/errors) in Build time. However, when I run the App and click the table cell triggering the functions above, Xcode console shows an Auto Layout error:

2019-07-18 15:35:03.472831+0800 MP4Convert[2797:357238] [LayoutConstraints] 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. 
(
    "<NSLayoutConstraint:0x2808bf8e0 UIView:0x104f16800.width == - 16   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x2808bf8e0 UIView:0x104f16800.width == - 16   (active)>

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

The value - 16 never appears in the all constraints. I try to add identifiers to existing constraints, but seems the NSLayoutConstraints mentioned above does not exist.

What did I miss?

The UIViewController hierarchy is very simple:

UIView > UITableView > UITableViewCell

There is no visual inconsistency when displaying in device's screen.

Xcode 10.2.1, iOS 12.3.1 on iPhone Xr device

Raptor
  • 53,206
  • 45
  • 230
  • 366
  • 1
    While this comment will sound like a "me to" issue, since iOS 12.3 update and the last Xcode update (not Beta), this issue has been occurring for my whole team. MY best guess is that this is an issue with the Apple engineers implementation, not your code. You could always set a symbollic break point, which we did, but we were led to a memory pointer, not a fault in our own implementation. – App Dev Guy Jul 18 '19 at 07:47
  • I have the same issue on iOS 12.4 and Xcode 10.3. – Adar Hefer Aug 13 '19 at 07:56

0 Answers0