Saturday, November 16, 2024
HomeiOS Developmentswift - iOS UITableView Ambiguous Structure at Runtime

swift – iOS UITableView Ambiguous Structure at Runtime

[ad_1]

I am getting an ambiguous structure error throughout runtime for my app and have tried fixing it for a number of days now with out success. My app is a to do listing, and I’ve a UITableView that accommodates UITableViewCells of various heights. If I drag a cell all the way down to the underside slowly and the web page begins to scroll, I get the error. see video of error situation

Right here is the error I get:

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this within the debugger.
The strategies within the UIConstraintBasedLayoutDebugging class on UIView listed in <UIKitCore/UIView.h> may be useful.
2022-03-12 11:18:28.445423-0800 Motion[83734:5205929] [LayoutConstraints] Unable to concurrently fulfill constraints.
    Most likely at the least one of many constraints within the following listing is one you don't need. 
    Do this: 
        (1) have a look at every constraint and take a look at to determine which you do not count on; 
        (2) discover the code that added the undesirable constraint or constraints and repair it. 
(
    "<NSLayoutConstraint:0x600003361590 V:|-(14)-[UILabel:0x1541a05d0]   (energetic, names: '|':UITableViewCellContentView:0x15419ef60 )>",
    "<NSLayoutConstraint:0x600003361680 V:[UILabel:0x1541a05d0]-(14)-|   (energetic, names: '|':UITableViewCellContentView:0x15419ef60 )>",
    "<NSLayoutConstraint:0x600003361bd0 'UIView-Encapsulated-Structure-Peak' UITableViewCellContentView:0x15419ef60.top == 0   (energetic)>"
)

I set a symbolic breakpoint as advised and get this extra data (4th line has “AMBIGUOUS LAYOUT”):

|   |   |   |   |   |   |   *<UILayoutGuide: 0x600003f7c380 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 94}, {375, 684}}, owningView = <UIView: 0x132006ea0; body = (0 0; 375 812); autoresize = W+H; layer = <CALayer: 0x600000679480>>>
|   |   |   |   |   |   |   *UIView:0x132007010
|   |   |   |   |   |   |   |   *UITableView:0x13300c000
|   |   |   |   |   |   |   |   |   *<UIFocusContainerGuide: 0x60000396c4b0 - "UITableViewContentFocusContainerGuide", layoutFrame = {{0, 0}, {375, 684}}, owningView = <UITableView: 0x13300c000; body = (0 0; 375 684); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x6000008dc5a0>; layer = <CALayer: 0x6000006597e0>; contentOffset: {0, 0}; contentSize: {375, 2783.9999949137377}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <Motion.ProjectController: 0x130e085e0>>>- AMBIGUOUS LAYOUT for UIFocusContainerGuide:0x60000396c4b0'UITableViewContentFocusContainerGuide'.minX{id: 3169}, UIFocusContainerGuide:0x60000396c4b0'UITableViewContentFocusContainerGuide'.minY{id: 3170}, UIFocusContainerGuide:0x60000396c4b0'UITableViewContentFocusContainerGuide'.Width{id: 3171}, UIFocusContainerGuide:0x60000396c4b0'UITableViewContentFocusContainerGuide'.Peak{id: 3172}
|   |   |   |   |   |   |   |   |   Motion.ActionCellView:0x12f0a1600'ReusableCell'
|   |   |   |   |   |   |   |   |   |   _UISystemBackgroundView:0x12de973f0
|   |   |   |   |   |   |   |   |   |   |   UIView:0x12de95f90
|   |   |   |   |   |   |   |   |   |   •UITableViewCellContentView:0x12de962a0
|   |   |   |   |   |   |   |   |   |   |   *UIButton:0x12de96440
|   |   |   |   |   |   |   |   |   |   |   |   _UISystemBackgroundView:0x12de968e0
|   |   |   |   |   |   |   |   |   |   |   |   UIImageView:0x12de96700
|   |   |   |   |   |   |   |   |   |   |   *UILabel:0x12de96aa0
|   |   |   |   |   |   |   |   |   |   _UITableViewCellSeparatorView:0x12de97080
|   |   |   |   |   |   |   |   |   |   _UITableViewCellSeparatorView:0x12de99c70
|   |   |   |   |   |   |   |   |   |   _UITableViewCellSeparatorView:0x1309081d0

Right here is how I’ve arrange the desk view in my controller’s viewDidLoad:

tableView.register(UINib(nibName: Ok.Motion.cellNibName, bundle: nil), forCellReuseIdentifier: Ok.Motion.cellIdentifier)
tableView.dataSource = self
tableView.dragDelegate = self
tableView.dropDelegate = self
tableView.delegate = self
tableView.showsVerticalScrollIndicator = false
        

Right here is the UITableViewDataSource implementation:

extension ProjectController: UITableViewDataSource {
    func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
        return tableView.rowHeight
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableView.automaticDimension
    }

    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
        if let venture = mannequin.initiatives.knowledge[projectId!] {
            return venture.actionIds.rely
        }
        
        return 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: Ok.Motion.cellIdentifier, for: indexPath) as! ActionCellView
        
        if let venture = mannequin.initiatives.knowledge[projectId!] {
            let actionId = venture.actionIds[indexPath.row]
            let motion = mannequin.actions.knowledge[actionId]!
            
            cell.titleLabel.textual content = motion.title
            cell.delegate = self
            cell.actionId = actionId
            
            if motion.scheduled != nil {
                cell.label = motion.scheduled!.toString()
            }
        }
        
        return cell
    }
}

I’ve additionally applied UITableViewDragDelegate:

extension ProjectController: UITableViewDragDelegate {
    func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
        let dragItem = UIDragItem(itemProvider: NSItemProvider())
        return [ dragItem ]
    }
    
    func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
        let venture = mannequin.initiatives.knowledge[projectId!]!
        let actionId = venture.actionIds[sourceIndexPath.row]
        mannequin.moveAction(actionId, inProject: projectId!, toRank: destinationIndexPath.row)
    }
}

Screenshot of Desk View constraints

Screenshot of Desk View cell Label constraints

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments