Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController modalTransitionStyle]: - objective-c

i used the following code to display my image picker controll.
IPopoverController *popoverController = [[[UIPopoverController alloc] initWithContentViewController:myImagePicker] retain];
[self presentModalViewController:popoverController animated:YES];
but there is a error that shows
working with image view[14335:207] *
Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'-[UIPopoverController
modalTransitionStyle]: unrecognized
selector sent to instance 0x6415950'.
can any one help me please.

You need to use this...
[popoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Or one of the other present methods, check the Apple docs.

The short answer is that you cannot use UIPopoverController to present it as a modal one. Please try using UIViewController instead.
You probably will need to subclass it and either load it from some nib or create its view content manually in loadView method.

Related

Reload Data throwing unrecognized selector sent to instance

I seem to be experiencing a small error when dismissing a view and navigating back to a ViewController (with a UITableView)
This is the code that loads the data into the tableView
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[getData getSavedTanks:^(NSArray *results) {
self.array = results;
[self.tankList reloadData];
NSLog(#"%#", results);
}];
}
The followup view in the stack is properly called, but when the view is dismissed, it seems as though the tableView has trouble reloading the data, and is throwing this error:
2014-04-28 21:15:57.698 ReefTrack[10205:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFObject reloadData]: unrecognized selector sent to instance 0x10be93210'
Not really sure how to handle this. I'm having trouble understanding why reloadData is throwing an error. I checked to see if there are any errant Segues pointing towards reload data but there doesn't appear to be. Anyone have any thoughts on this?
UPDATE:
This was solved by placing the entire function in viewDidLoad.

ECSlidingViewController not First View

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"];
}

"Unrecognized selector sent to instance" error

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.

Use property leftItemsSupplementBackButton of UINavigationItem Class

In my app I want to show a button item together the back button in the navigation bar. I read the doc of the UINavigationItem class and I found the property leftItemsSupplementBackButton that seems to be just for me. Then I used this line of code:
- (void)viewDidLoad{
[super viewDidLoad];
[self.navigationItem setLeftItemsSupplementBackButton:YES];
}
But when I run the app I get this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationItem setLeftItemsSupplementBackButton:]: unrecognized selector sent to instance 0x10faefb0'
and the 0x10faefb0 instance is:
_navigationItem UINavigationItem * 0x10faefb0
From the error seems that self.navigationItem doesn't have this property as is said in the apple class reference. Where i'm wrong?
That's for iOS 5 only. Are you running on iOS 4?

add SplitViewController view trouble under iOS5

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 :)