I’m getting constraint warnings when pushing SBUChannelViewController(). I tried to shrink the problem to the shortest possible source code:
import UIKit
import SendBirdUIKit
class ViewController: UIViewController {
private enum Constants {
static let appId = ""
static let userId = ""
static let token = ""
}
override func viewDidLoad() {
super.viewDidLoad()
SBUMain.initialize(applicationId: Constants.appId)
SBUGlobals.CurrentUser = SBUUser(userId: Constants.userId)
SBUGlobals.AccessToken = Constants.token
SBUMain.connect(completionHandler: { user, error in
print("user: \(user), error: \(error)")
})
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let navvc = UINavigationController(rootViewController: ViewController2())
navvc.modalPresentationStyle = .fullScreen
present(navvc, animated: false)
}
}
class ViewController2: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let btn = UIButton(frame: .init(x: 100, y: 200, width: 200, height: 50))
view.addSubview(btn)
btn.setTitle("open channel", for: .normal)
btn.addTarget(self, action: #selector(openChannel), for: .touchUpInside)
}
@objc func openChannel() {
let channelListQuery = SBDGroupChannel.createMyGroupChannelListQuery()
channelListQuery?.loadNextPage(completionHandler: { [weak self] channels, error in
guard let channel = channels?.first else {
print("loadNextPageError: \(error)")
return
}
let channelVC = SBUChannelViewController(channel: channel)
self?.navigationController?.pushViewController(channelVC, animated: true)
})
}
}
SendBirdSDK: 3.0.211
SendBirdUIKit: 1.2.11
Device: iPhone XR, iOS 14.3
Here is one of the warnings:
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.
2020-12-21 16:56:21.533222+0100 Messaging[32290:822928] [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:0x6000000a82d0 UIView:0x7fd985637840.width == 0 (active)>",
"<NSLayoutConstraint:0x6000000dfac0 H:|-(20)-[UIStackView:0x7fd98561b820] (active, names: '|':SendBirdUIKit.SBUMessageInputView:0x7fd985636d00 )>",
"<NSLayoutConstraint:0x6000000dfb10 UIStackView:0x7fd98561b820.trailing == SendBirdUIKit.SBUMessageInputView:0x7fd985636d00.trailing - 16 (active)>",
"<NSLayoutConstraint:0x600000096210 H:|-(0)-[SendBirdUIKit.SBUMessageInputView:0x7fd985636d00](LTR) (active, names: '|':UIView:0x7fd985622ec0 )>",
"<NSLayoutConstraint:0x600000096260 SendBirdUIKit.SBUMessageInputView:0x7fd985636d00.right == UIView:0x7fd985622ec0.right (active)>",
"<NSLayoutConstraint:0x600000093930 'UISV-alignment' UIView:0x7fd985636f60.leading == UIView:0x7fd985637840.leading (active)>",
"<NSLayoutConstraint:0x600000093a20 'UISV-alignment' UIView:0x7fd985636f60.trailing == UIView:0x7fd985637840.trailing (active)>",
"<NSLayoutConstraint:0x6000000937a0 'UISV-canvas-connection' UIStackView:0x7fd98561b820.leading == UIView:0x7fd985636f60.leading (active)>",
"<NSLayoutConstraint:0x6000000937f0 'UISV-canvas-connection' H:[UIView:0x7fd985636f60]-(0)-| (active, names: '|':UIStackView:0x7fd98561b820 )>",
"<NSLayoutConstraint:0x6000000dd0e0 'UIView-Encapsulated-Layout-Width' UIView:0x7fd985622ec0.width == 414 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000000a82d0 UIView:0x7fd985637840.width == 0 (active)>