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];
}
Related
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.
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;
error occurs with below code---Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Could not load
NIB in bundle:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DetailViewController *dvc =[[DetailViewController alloc]initWithNibName:#"DetailViewController" bundle:nil];
dvc.index = indexPath.row;
[self.navigationController pushViewController:dvc animated:YES];
}
As mentioned in your comments you are using Storyboard, then this is not how you will initialize an object of UIViewController with the storyboard.
You must create object like this
DetailViewController *vcDetailViewController = [[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"DetailViewController"];
vcDetailViewController.index = indexPath.row;
[self.navigationController pushViewController:vcDetailViewController animated:YES];
Also, you need to give StoryBoard Id to your view controller, check image
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?
I have 2 view controller
VC1 has button
in this button action
- (IBAction)clickSearch:(id)sender
{
NSArray *vc=[self.navigationController viewControllers];
ViewControllerSearch *vcSearch=nil;
for (int i=0; i<[vc count]; i++)
{
UIViewController *tempVC=[vc objectAtIndex:i];
if([tempVC isKindOfClass:[ViewControllerSearch class]])
{
vcSearch=[vc objectAtIndex:i];
break;
}
}
if(vcSearch)
{
[self.navigationController popToViewController:vcSearch animated:YES];
}
else
{
ViewControllerSearch *vc3New= [[ViewControllerSearch alloc]initWithNibName:#"ViewControllerSearch" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:vc3New animated:YES];
vc3New = nil;
}
}
ViewControllerSearch id my second view controller.these two view s connected with push segue.
when i click the button coming this error.
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Could not load NIB in bundle: 'NSBundle </Users/Ravi/Library/Application Support/iPhone Simulator/6.0/Applications/42268111-F290-40B8-B893-4649852F762C/coffee break app.app> (loaded)' with name 'ViewControllerSearch''
how can i fixed this error?please give me idea.
Are you certain your Nib is called 'ViewControllerSearch.xib'?
Also you don't need to nil out vc3New - in fact you probably shouldn't.
UPDATED
...to load from a storyboard, as mentioned in the comment, you need to do something like this:
UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
ViewControllerSearch* controller = [storyBoard instantiateViewControllerWithIdentifier:#"ViewControllerSearch"];
1) Make to sure the storyboard identifier matches what you've named it
2) Make sure you've set/used the correct identifier, in the storyboard, for your controller