When I trying to add SplitViewController to view hierarchy application terminates with:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController initWithContentViewController:] must not be called with nil.'
SplitViewController *viewController = [[SplitViewController alloc] init];
[self.window addSubview:viewController.view];
Where SplitViewController subclass of UISplitViewController
I don't understand which popover it means.
This trouble appear only on iOS5.
After initializing viewController, you should set its viewControllers with viewController.viewControllers = [NSArray arrayWithObjects:leftNavigationController, rightNavigationController, nil];
Else, your SplitViewController does not know what to display on the left and on the right.
Pay attention also to the delegate.
Please check if this helps :)
Related
My application start with a view thats not use ECSlidingViewController, and then have a button to another that uses it.
In switching the views using Storyboard Segue, but I'm getting error.
What should I add to btnGoSecondView to load ECSlidingViewController properly?
Code:
-(IBAction)btnGoSecondView:(id)sender {
[self performSegueWithIdentifier:#"SecondViewShow" sender:self];
}
Error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
i think you should make some initialview first, and make that view became initial view controller and make an identifier for every each view controller.
something like this ..
self.viewcontroller = [storyboard instantiateViewControllerWithIdentifier:#"home"];
Based on the error you're getting an object is trying to be inserted into a mutable array but it hasn't been initialised. Where is the exception thrown in your code?
Try work out where the array is being accessed and why it's null. The NSMutableArray may not have been initialised in which case you'll need to initialise it.
NSMutableArray *arrayName = [NSMutableArray new];
Another thought: Before the ECSlidingViewController is presented I think you need to set it's topViewController. You could add it in -prepareForSegue:sender: or in the viewDidLoad of the viewController to be presented.
Something like this perhaps:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
ECSlidingViewController *slidingViewController = (ECSlidingViewController *)segue.destinationViewController;
slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"FirstTop"];
}
I use in my project only xib files. Now i need a static tableview for a settings view. I want to combinied xib and one storyboard(for the tableview).
I add a storyboard with one viewcontroller in my projekt. After than i add a identifier(SettingsView) for this viewcontroller. the following code is executed when the button was pressed:
SettingsView *CustomViewController = [[UIStoryboard storyboardWithName:#"Storyboard" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:#"SettingsView"];
[self presentModalViewController:CustomViewController animated:YES];
My Application crashed when i push the setting button:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'SettingsView''
Please make sure that you added the StoryBoard ID as follows in the picture attached.
The storyboard and individual view controller that you are attempting to instantiate, names have match exactly. Otherwise, the rest of what you are doing is correct from what I can see.
I created a Universal window app in Xcode 4.3.3. Later I added one View Controller(UniversalRootViewController) class without XIB. Then I created two XIB files(RootViewController_iPhone, RootViewController_iPad) and then connect these iPhone XIB file RootViewController_iPhone to the UniversalRootViewController class: RootViewController_iPhone -> Select File's Owner and changed the class name in Identity Inspector as UniversalRootViewController and then connect the view as outlet to UniversalViewController and did the same thing for RootViewController_iPad.
In App Delegate , I added the following lines of code.
UniversalRootViewController *controller = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
controller = [[UniversalRootViewController alloc] initWithNibName:#"RootViewController_iPad" bundle:[NSBundle mainBundle]];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[self.window addSubview:navigationController.view];
}
else
{
controller = [[UniversalRootViewController alloc] initWithNibName:#"RootViewController_iPhone" bundle:[NSBundle mainBundle]];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[self.window addSubview:controller];
}
Also I added these two key-value pairs in UniversalApp-Info.plist
Main nib file base name : RootViewController_iPhone
Main nib file base name (iPad) : RootViewController_iPad
When I run this application, the app creates by displaying the following error message.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
I connected XIB files properly to View Controller. I don't know why the app crashes. Please tell me the solution.
You will have to set the view outlet in the File's Owner to each view in the XIB file:
- Go to one of the XIB file (iphone for example) and drag with the left mouse button from the file owner to the top view below in objects. Select view.
- Do the same for the other XIB file
I solved my problem by removing the two key-value pairs of Nib files in Universal-Info.plist. Now the app works perfectly without any crash.
Part of my AppDelegate code is:
UITabBarController *tabBarController
= (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController
= [[tabBarController viewControllers] objectAtIndex:0];
PilotosViewController *playersViewController
= [[navigationController viewControllers] objectAtIndex:0];
playersViewController.drivers = players;
But I get this exception:
-[UIViewController viewControllers]: unrecognized selector sent to instance 0x6a75770
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController
viewControllers]: unrecognized selector sent to instance 0x6a75770'
Where is the mistake?
I met the same issue, because I followed the steps by the author, but
UINavigationController *navigationController
= [[tabBarController viewControllers] objectAtIndex:0];
this is what which made the crash, because navigationController is not at index=0,
I did exchange the locations of the two tab bar items, then it works.
You need to make sure that you connect things properly in your XIB or storyboard. The exception is showing you that the object is of type ViewController when you send [tabBarController viewControllers] and you were expecting a UITabBarController. That's why you're getting '-[ViewController viewControllers]:. Make sure that your root view controller really is a tab view controller.
You are obviously receiving different type of object on index = 0.
If you are using storyboard go there and open Navigator > find specific controller > see Relationships. This order can be used when referencing its viewControllers collection.
I have a table view, and in one of the cells, it says "contact". Upon selecting this cell, I'd like to push in a MFMailComposeViewController.
I can only seem to present this MFMailComposeViewController modally. What is the problem here?
Thanks!
Relevant code frag:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
//*works*//[self.navigationController presentModalViewController:controller animated:YES];
//*broken*//[self.navigationController pushViewController:controller animated:YES];
}
The error that I get is: " * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
* Call stack at first throw:"
So it looks like I have a navigationController already, and since MFMailComposeViewController is a subclass of UINavigationController, I'm pushing a navController onto another navController?
I want my UI to be consistent, so I want to push a MFMailComposeViewController onto the nav stack rather than present it modally.
This is because MFMailComposeViewController isn't a subclass of UIViewController but of UINavigationController. UINavigationController throws an exception when you're attempting to push a UINavigationController or subclass of UINavigationController onto an existing stack. Presenting a UINavigationController modally is permitted.
According to Apple documentation
To display the view managed by this view controller, you can use any of the standard techniques for displaying view controllers
So what you are trying to do is supposed to work in both cases. Did you have a look at the logs ?
I would have bet your navigationController is nil, because this typically happens when you are using a plain UIViewController (not embedded in a UINavigationController, but it you actually present your modal view onto the navigationController, it may not be nil.