iOS 'NSInternalInconsistencyException', reason: 'UICollectionViewFlowLayout internal error - ios

I have a collection view inside self-sizing tableview. When user tap on collection view, I present another view.
I can still present that view in portrait orientation. But when I rotate to landscape, I got this error and crash. How shall I do?
2017-01-23 16:52:16.448417 SWEET Mini[1638:647130] * Assertion
failure in -[_UIFlowLayoutSection
computeLayoutInRect:forSection:invalidating:invalidationContext:],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.6.22/UIFlowLayoutSupport.m:823
2017-01-23 16:52:16.451537 SWEET Mini[1638:647130] * Terminating app
due to uncaught exception 'NSInternalInconsistencyException', reason:
'UICollectionViewFlowLayout internal error'
I just present another view like this.
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.zoomPhotosToFill = NO;
[browser setCurrentPhotoIndex:(indexPath.row)];
browser.enableSwipeToDismiss = YES;
UINavigationController *browseNav = [[UINavigationController alloc] initWithRootViewController:browser];
if ([[AppDelegate instance].window.rootViewController isKindOfClass:[UINavigationController class]])
{
UINavigationController *nav = (UINavigationController *) [AppDelegate instance].window.rootViewController;
[nav presentViewController:browseNav animated:YES completion:nil];
}
else if ([[AppDelegate instance].window.rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController *tab = (UITabBarController *) [AppDelegate instance].window.rootViewController;
[tab presentViewController:browseNav animated:YES completion:nil];
}
}

I had the same issue with the same error message. Turns out, it's only happening on the simulator, everything works fine on real device.

Related

Make SWRevealViewController as rootViewController after Sign In when it has tabbarController as sw_front objC

This is my Storyboards :
Say I have a Sign In viewController above these and from where I want to make SWRevealViewController as my rootViewController, so that It can work perfectly. With the below code, From my leftMenuViewController I can select my tabBar with desired ViewController perfectly.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITabBarController *tabBarController = (UITabBarController *)self.revealViewController.frontViewController;
UINavigationController *navController = tabBarController.viewControllers[indexPath.row];
[navController popToRootViewControllerAnimated:NO];
tabBarController.selectedIndex = indexPath.row;
self.revealViewController.rearViewRevealOverdraw = 0.0f;
[self.revealViewController pushFrontViewController:tabBarController animated:YES];
}
But it is not working in App delegate or in SignInViewController.
- (void)checkIfUserSignedIn
{
if ([ManagerClass getBOOLTypeUserDefaultForKey:#"isSignedIn"] == YES) {
UITabBarController *tabBarController = (UITabBarController *)self.revealViewController.frontViewController;
UINavigationController *navController = tabBarController.viewControllers[0];
[navController popToRootViewControllerAnimated:NO];
tabBarController.selectedIndex = 0;
self.revealViewController.rearViewRevealOverdraw = 0.0f;
[self.revealViewController pushFrontViewController:tabBarController animated:YES];
self.window.rootViewController = tabBarController;
} else {
}
}
It is giving this in log:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
Any help will be highly appreciated. Thanks a lot in advance.
Have a good day.
All I need to do is this:
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:mainStoryboard bundle:[NSBundle mainBundle]];
SWRevealViewController *controller = (SWRevealViewController *)[storyBoard instantiateViewControllerWithIdentifier:#"RevealViewControllerID"];
[self.window setRootViewController:controller];
Just set SWRevealViewController as your rootViewController of the project. :)
your answer above is right but the crash you mentioned in you question
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
was caused from you storyboard because the SWRevealVC in the image you posted above is not set to initial view controller, select your view controller then from Attribute Inspector check the option available Is Initial View Controller like
you should see an Arrow pointing from you SWRevealVC

3D Touch for Shortcuts Crashes

My app is a single-view NavigationController as a root view controller style app. In it, I have a few different shortcut items for using 3D Touch. I have them all set up in the Info.plist fine (I've done this before with a Tab Bar app and it worked fine), but it crashes every time an shortcut action is pressed. Here is my the code used in AppDelegate in Obj-C.
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
UINavigationController *nav = (UINavigationController *) self.theMainView.view;
NSLog(#"%#", shortcutItem.type);
if ([shortcutItem.type isEqualToString:#"com.316apps.Fritch.inviteFriends"]) {
ImagePicker *vimeo= [[ImagePicker alloc] init];
[nav pushViewController:vimeo animated:YES];
}
if ([shortcutItem.type isEqualToString:#"com.316apps.Fritch.viewAlerts"]) {
NewsViewController *dvController8 = [[NewsViewController alloc] initWithNibName:#"NewsViewController" bundle:[NSBundle mainBundle]];
[nav pushViewController:dvController8 animated:YES];
}
if ([shortcutItem.type isEqualToString:#"com.316apps.Fritch.viewDirectory"]) {
DirectoryViewController *dvController8 = [[DirectoryViewController alloc] init];
[nav pushViewController:dvController8 animated:YES];
}
}
Crash Log:
com.316apps.Fritch.viewDirectory
2017-01-19 22:44:23.305906 Fritch[3956:925348] -[UILayoutContainerView pushViewController:animated:]: unrecognized selector sent to instance 0x101837530
2017-01-19 22:44:23.306768 Fritch[3956:925348] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILayoutContainerView pushViewController:animated:]: unrecognized selector sent to instance
UINavigationController *nav = (UINavigationController *) self.theMainView.view;
The reason of crashing is you are getting the view, not ViewController. So self.theMainView.view cannot convert to UINavigationController. If your self.theMainView is correct, fix that crash by using:
UINavigationController *nav = (UINavigationController *) self.theMainView;

Crash when trying to Present View Controller

I am experiencing a crash on my app when the following code is executed:
- (void)presentSearchViewController
{
if(!_searchController)
{
SearchStickerViewController *searchController = [[SearchStickerViewController alloc] initWithNibName:#"SearchStickerViewController" bundle:nil];
searchController.delegate = self;
[searchController.view setFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height)];
_searchController = searchController;
}
[self addChildViewController:_searchController];
[self.view addSubview:_searchController.view];
[_searchController didMoveToParentViewController:self];
}
The strange thing is that I am using the same code to push other ViewControllers I have and it works just fine. It doesn't crash always, it starts crashing after I go back and forth for around the 5th time (maybe it crashes on the 6th or 7th).
The error I get is:
Terminating app due to uncaught exception
UIViewControllerHierarchyInconsistency', reason: 'child view
controller:< UICompatibilityInputViewController: 0x1004e6af0> should
have parent view controller:< CKFullScreenAppViewController:
0x104e458f0> but actual parent is < UIInputWindowController:
0x100830200>
The code I am using to dismiss the ViewController is:
- (void)dismissSearchResultsViewController
{
[_searchController willMoveToParentViewController:nil];
[_searchController.view removeFromSuperview];
[_searchController removeFromParentViewController];
}
Any ideas on how to troubleshoot/fix this?

Getting error 'UINavigationControllers are not allowed in a navigation controller!'

Trying to implement a slide out menu in one of my apps. When a user presses an option in the side menu it takes them to another view.
Was working find with the defaults that came in the example of the slide out menu I am using, but when I have my own in it is throwing up an error.
Here is the code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
DEMONavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:#"contentController"];
NSLog(#"Row preseed%ld", (long)indexPath.row);
NSLog(#"section preseed%ld", (long)indexPath.section);
if (indexPath.section == 0 && indexPath.row == 0) {
QuickGlanceViewController *homeViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"homeController"];
navigationController.viewControllers = #[homeViewController];
}
self.frostedViewController.contentViewController = navigationController;
[self.frostedViewController hideMenuViewController];
}
And here is the error:
Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'UINavigationControllers
are not allowed in a navigation controller!'
Anyone have any idea what the problem may be?
It looks like QuickGlanceViewController is a subclass of UINavigationController have a look at your nib layout in the storyboard.
You can't have a UINavigationController inside of another UINavigationController.

QLPreviewController crashing when tapping share button, internal consistency nib bundle error

I'm presenting a QLPreviewController modally. Everything works-- it pops up, shows the preview item and everything. However, once the share button is tapped, the app crashes on the device and in the simulator with this:
2013-05-03 20:10:53.563 appname[16860:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <{{app_path}}> (loaded)' with name '_UIDocumentActivityViewController''
Here is the relevant code:
#pragma mark HVSchedulesDelegate
- (void)schedulePDFReceived {
QLPreviewController *previewController = [[QLPreviewController alloc] init];
[previewController setDataSource:self];
[self presentViewController:previewController animated:YES completion:nil];
}
#pragma mark QLPreviewControllerDataSource
- (NSInteger) numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
return 1;
}
- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
return [NSURL fileURLWithPath:self.schedulesProxy.pdfPath];
}

Resources