0

I have a table view that displays a series of images that are pre loaded in an array, however whe I run the code it crushes with this error "

   2019-08-22 12:19:10.756047+0200 Wee'd like to help[44388:5089505] 
   libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not 
   supported on this platform.
2019-08-22 12:19:10.884482+0200 Wee'd like to help[44388:5089505] [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:0x6000038cb890 UILayoutGuide:0x6000022d3720'UIViewSafeAreaLayoutGuide'.trailing == UIStackView:0x7fdffdc24870.trailing + 1   (active)>",
    "<NSLayoutConstraint:0x6000038f7ac0 H:[UIStackView:0x7fdffdc24870]-(16)-|   (active, names: '|':UIView:0x7fdffdc233d0 )>",
    "<NSLayoutConstraint:0x6000038f75c0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide:0x6000022d3720'UIViewSafeAreaLayoutGuide']-(0)-|(LTR)   (active, names: '|':UIView:0x7fdffdc233d0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000038cb890 UILayoutGuide:0x6000022d3720'UIViewSafeAreaLayoutGuide'.trailing == UIStackView:0x7fdffdc24870.trailing + 1   (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.
2019-08-22 12:19:12.780647+0200 Wee'd like to help[44388:5089505] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-lwe-wj-C4h" from storyboard "Main", but didn't get a UITableView.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010b04f1bb __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x000000010934a735 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010b04f015 +[NSException raise:format:] + 197
    3   UIKitCore                           0x0000000112b969dc -[UITableViewController loadView] + 621
    4   UIKitCore                           0x0000000112ba60ee -[UIViewController loadViewIfRequired] + 175
    5   UIKitCore                           0x0000000112ba6940 -[UIViewController view] + 27
    6   UIKitCore                           0x0000000112af0a9b -[UINavigationController _startCustomTransition:] + 931
    7   UIKitCore                           0x0000000112b073f0 -[UINavigationController _startDeferredTransitionIfNeeded:] + 741
    8   UIKitCore                           0x0000000112b087e0 -[UINavigationController __viewWillLayoutSubviews] + 150
    9   UIKitCore                           0x0000000112ae8600 -[UILayoutContainerView layoutSubviews] + 217
    10  UIKitCore                           0x00000001136af795 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1441
    11  QuartzCore                          0x0000000109d9fb19 -[CALayer layoutSublayers] + 175
    12  QuartzCore                          0x0000000109da49d3 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
    13  QuartzCore                          0x0000000109d1d7ca _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 342
    14  QuartzCore                          0x0000000109d5497e _ZN2CA11Transaction6commitEv + 576
    15  QuartzCore                          0x0000000109d556fa _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
    16  CoreFoundation                      0x000000010afb3c27 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    17  CoreFoundation                      0x000000010afae0be __CFRunLoopDoObservers + 430
    18  CoreFoundation                      0x000000010afae751 __CFRunLoopRun + 1537
    19  CoreFoundation                      0x000000010afade11 CFRunLoopRunSpecific + 625
    20  GraphicsServices                    0x000000010f5d51dd GSEventRunModal + 62
    21  UIKitCore                           0x00000001131c581d UIApplicationMain + 140
    22  Wee'd like to help                  0x00000001089f0bf7 main + 71
    23  libdyld.dylib                       0x000000010c4e8575 start + 1
    24  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException"

I already tried to reset and clear the costraints

this is my tableViewController code

class StrainTableViewController: UITableViewController {
    var diseasePics = [UIImage()]
    override func viewDidLoad() {
        super.viewDidLoad()
        loadPics()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem
    }

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return diseasePics.count
    }

    func loadPics(){
        let anxietyPic = UIImage(named: "Anxiety")
        let depressionPic = UIImage(named: "Depression")
        let arthritisPic = UIImage(named: "Arthritis")
        let crampsPic = UIImage(named: "Cramps")
        let fatiguePic = UIImage(named: "Fatigue")
        let headachePic = UIImage(named: "Headache")

        diseasePics = [anxietyPic,depressionPic, arthritisPic, crampsPic, fatiguePic,headachePic] as! [UIImage] 
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "StrainCell", for: indexPath) as! StrainTableViewCell

        let image = diseasePics[indexPath.row]
        cell.diseaseImage.image = image
        return cell
    }
}

I really don't think that the problem are the constraints, I believe there is something wrong in here

gloria00
  • 265
  • 2
  • 15
  • Revise the 2nd line. – El Tomato Aug 22 '19 at 10:27
  • I do not see any constraint code. The issue must be in your layout from StrainCell. Try showing only one cell and with the Debug View Hierarchy and the Console log find the view with issue. – Deryck Lucian Aug 22 '19 at 10:28
  • What does it mean? – gloria00 Aug 22 '19 at 10:28
  • @gloria00 can you please add the error as shown in the debug output. For example have a look at this [question](https://stackoverflow.com/q/14327145/4056108). This will allow us to understand what is causing the crash. – chirag90 Aug 22 '19 at 10:32
  • I added the full error stack – gloria00 Aug 22 '19 at 10:53
  • Your app crashes because of this line: ```*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-lwe-wj-C4h" from storyboard "Main", but didn't get a UITableView.``` Constraints don't crush an app. – Starsky Aug 22 '19 at 13:09

2 Answers2

0

This error is due to your UITableViewController doesn't contain UITableView check your storyboard and add TableView in your UITableViewController.

and you also need to register your cell in viewDidLoad() method before calling loadPics() function like:

tableView.register(UINib(nibName: "StrainTableViewCell", bundle: nil), forCellReuseIdentifier: "StrainCell")
  • Tried that. My storyboard already has a tableView, also tried to add the above line but it didn't work – gloria00 Aug 23 '19 at 07:10
  • `*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-lwe-wj-C4h" from storyboard "Main", but didn't get a UITableView.' ` Check your error it is clearly saying the viewcontroller with this "UIViewController-lwe-wj-C4h" identifier doesn't have any UITableview. Kindly check your storyboard that you are assigning a write controller. – Munzareen Atique Aug 23 '19 at 12:25
0

Turned out the problem was the loadPics method. I initialized the pictures without using any method and it worked fine

gloria00
  • 265
  • 2
  • 15