Error when moving view Controller - ios

I get an error saying
*** Assertion failure in -[HatsViewController loadView], /SourceCache/UIKit/UIKit-2380.17/UICollectionViewController.m:104
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UICollectionViewController loadView] loaded the "FCD-ki-UFO-view-1vb-8P-s3C" nib but didn't get a UICollectionView.'
*** First throw call stack:
(0x3467c2a3 0x3c36097f 0x3467c15d 0x34f51ab7 0x368aaa95 0x364a346d 0x3652f353 0x36570d11 0x3656ffe7 0x366923ef 0x3656f0c5 0x3656f077 0x3656f055 0x3656e90b 0x3656ee01 0x364975f1 0x36484801 0x3648411b 0x3818b5a3 0x3818b1d3 0x34651173 0x34651117 0x3464ff99 0x345c2ebd 0x345c2d49 0x3818a2eb 0x364d8301 0xc0dfd 0x3c797b20)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Why does this happen and how can I fix it?

When you’re using a UICollectionViewController, the view outlet needs to be connected to a UICollectionView in your storyboard; if it’s a UIView of another class, it’ll crash.

check HatsViewController.h is inherited from UICollectionViewController but you have connected it view in your storyboard. Either it must be subclass of UIViewController or it is connected to UICollectionView in your storyboard.

Related

Terminating app due to uncaught exception [UIImageView _isResizable]

I'm getting an exception:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView _isResizable]: unrecognized selector sent to instance 0x7fe01fd0d470'
I just assigned an image to the imageView inside a custom cell using storyboard.
The code is clean. It doesn't have any warnings or errors.
Two reason of this error.
If you want to assign image write.
cell.image=[UIImage imagenamed:#"Name of your image "];
and another reason of this error is you can cut the link of imageView to the outlet.
Again make a new outlet and then check now imageView is working.
i think this will help u.
there may be two or more outlet references to one imageView which makes ambiguous
Please see once the name of image in swift file and StroryBoard. Compare them they must be same.
Also check the identifier of Cell.

Copying frame/bounds/constraints from one view to another

self.blurView = UIVisualEffectView(effect: UIBlurEffect(style: .ExtraLight)) as UIVisualEffectView
self.blurView.frame = self.filterPanel.frame
self.blurView.bounds = self.filterPanel.bounds
self.blurView.addConstraints(self.filterPanel.constraints())
self.view.insertSubview(self.blurView, belowSubview: self.filterPanel)
When attempting to run the code above in viewDidLoad it returns the error below. Why is this? I am simply trying to create a blur view with the same dimensions as the filterPanel view.
2015-02-15 14:44:37.929 App[568:182030] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x18eeac70 H:|-(0)-[UIView:0x1bbe0a70] (Names: '|':UIView:0x1bbe0a00 )>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
2015-02-15 14:44:37.944 App[568:182030] *** Assertion failure in -[UIVisualEffectView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /SourceCache/UIKit/UIKit-3318.16.25/NSLayoutConstraint_UIKitAdditions.m:560
2015-02-15 14:44:37.945 App[568:182030] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
*** First throw call stack:
(0x229ba49f 0x30174c8b 0x229ba375 0x2368bd1f 0x264a4295 0x25f63cd3 0x25f63b3f 0x25f63ab3 0x264a43d1 0x25f6c909 0x25f6c87d 0xffe30 0x1019dc 0x25e7b52f 0x25f25385 0x25f252ad 0x25f24843 0x25f24573 0x25f242dd 0x25f24271 0x25e78a6f 0x258a0a0d 0x2589c3e5 0x2589c26d 0x2589bc51 0x2589ba55 0x260dc885 0x260dd62d 0x260e7a39 0x260dba47 0x2914b0d1 0x22980d7d 0x22980041 0x2297e7c3 0x228cc3c1 0x228cc1d3 0x25edf9cf 0x25eda7b1 0xbd574 0xbd690 0x306f4aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Thanks in advance.
The constraints self.filterPanel.constraints() all presumably relate to self.filterPanel and its subviews. Setting those constraints on self.blurView doesn't magically change them to refer to self.blurView and its subviews. You're adding constraints to a view that has nothing to do with it or its subviews.
You would need to go through all of the constraints and build new constraints that are parallel in form but refer to the corresponding view within the self.blurView sub-hierarchy, which is not going to be easy. For one thing, you've just created self.blurView so it presumably has no subviews, yet.
You might try encoding the original view to an archive and then decoding that archive to produce a duplicate sub-hierarchy.

I can't solve "invalid nib registered for identifier (BNRItemCell)"

Going through the Big Nerd Ranch iOS book, and I'm on day 2 of trying to solve this and I'm going crazy - can anyone help?
I get the following error message:
2014-06-20 11:37:18.764 Homepwner[10388:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid nib registered for identifier (BNRItemCell) - nib must contain exactly one top level object which must be a UITableViewCell instance'
I've hooked up the BNRItemCell.xib to the corresponding class. Things fail after line 57 where the breakpoint is:
=======================================================
=======================================================
I know that it's gonna be something so basic that I'll kick myself.
Any help will be appreciated thanks!
Observing the TreeView on the left of the IB you have a UIView ( second top level element! ) below the UITableViewCell. Delete it and you should be fine!
I had this same issue. It turns out I had added another view by mistake on the .xib file

How to prevent UISearchBar from shifting up

I put UISearchBar under UIView as the picture below. The problem is - after finish search or click cancel, UISearchBar will shift to the top, then I get error message:
2014-05-22 15:45:18.663 MyAPP[14402:60b] *** Assertion failure in -[UITableView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2935.137/UIView.m:8794
2014-05-22 15:45:18.667 MyAPP[14402:60b] WARNING: GoogleAnalytics 3.06 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:49): Uncaught exception: Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.
2014-05-22 15:45:23.697 MyAPP[14402:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'
*** First throw call stack:
Question:
1) Is it possible to fix position of UISearchBar? and How to do that?
2) How to fix the error?

Exception: terminate called throwing an exceptionsharedlibrary apply-load-rules all

I am trying to pull a VC xib, by adding the view of controller on window's view. When I execute the program nothing appears (a black screen), and expectation was a button put on view of VC in xib.
But when I declare that this VC is my Project's main interface (Project Summary), then it throws the exception : terminate called throwing an exceptionsharedlibrary apply-load-rules all and application crashes.
Here is the code for didfinishlaunch (Appdelegate)
[self.window addSubview:rootViewController.view];
[self.window makeKeyAndVisible];
Can somebody assist on that.
Thanks
PS: the complete error is given below
2012-02-26 11:50:08.003 PasswordGeneratorTest[1161:f803] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
* First throw call stack:
(0x13b9052 0x154ad0a 0x13b8f11 0x9b0032 0x921f7b 0x921eeb 0x93cd60 0x22f91a 0x13bae1a 0x1324821 0x22e46e 0x230010 0x1014a 0x10461 0xf7c0 0x1e743 0x1f1f8 0x12aa9 0x12a3fa9 0x138d1c5 0x12f2022 0x12f090a 0x12efdb4 0x12efccb 0xf2a7 0x10a9b 0x1d42 0x1cb5)
terminate called throwing an exceptionsharedlibrary apply-load-rules all
Current language: auto; currently objective-c
Single stepping until exit from function __pthread_kill,
which has no line number information.
I can't see your stack trace code or the message the debugger is giving you, but there's ALWAYS 2 reasons why it would crash here:
rootViewController.view is nil or doesn't have its view outlet set in IB.
self.window is not set in code or doesn't have its outlet connected in IB.
Check all of your outlets and see if it fixes it.

Resources