Error Pushing a navigation controller is not supported [duplicate] - ios

This question already has an answer here:
Pushing data from a UITableViewCell to a UINavigationController
(1 answer)
Closed 8 years ago.
I have a UISearchDisplaycontroller that i have to push information to text fields and need to link it to a navigation view controller.
Here is the error -
2014-12-10 20:05:08.775 Contents Concepts Mobile[2785:333301] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
*** First throw call stack:
(0x2311dc1f 0x30b96c8b 0x26663207 0x268d0229 0x26662b43 0x266f2f67 0x267a4c0f 0x26656c4d 0x265d2aab 0x230e43b5 0x230e1a73 0x230e1e7b 0x23030211 0x23030023 0x2a3c00a9 0x2663c1d1 0xf0225 0x31116aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Here is my code -
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showRecipeDetail"]) {
NSIndexPath *indexPath = nil;
Recipe *recipe = nil;
if (self.searchDisplayController.active) {
indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
recipe = [searchResults objectAtIndex:indexPath.row];
} else {
indexPath = [self.tableView indexPathForSelectedRow];
recipe = [recipes objectAtIndex:indexPath.row];
}
RecipeDetailViewController *destViewController = segue.destinationViewController;
destViewController.recipe = recipe;
}
}

Can you also post your story board setting as well. It seems you have a linking problem between two different views. Cause the error message said you are trying to push the navigation controller and not the view controller.

Related

Unrecognized selector sent to instance UITableView cell push to TabbarController

I'm just trying send the mid to customerDetailviewcontroller and segue is going tabbar controller first.
There is my prepareforsegue method
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
ApiClass *apiClass = [self.customerCards objectAtIndex:indexPath.row];
CustomerDetailViewController *customerDetailViewController = (CustomerDetailViewController *)segue.destinationViewController;
customerDetailViewController.mid = apiClass.mid;
}
}
_mid NSString * #"1642"
That is the error.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarController setMid:]: unrecognized selector sent to instance 0x126e53580'
*** First throw call stack:
(0x1838d6530 0x1948ac0e4 0x1838dd5f4 0x1838da3ac 0x1837dec4c 0x1000ae2b4 0x1886b401c 0x18820ce14 0x1882ca6dc 0x188166b8c 0x1880d85f0 0x18388ed98 0x18388bd24 0x18388c104 0x1837b91f4 0x18cbdb6fc 0x18814a10c 0x1000e2b08 0x194f2aa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
There is the data I'm getting from json.So it is not nil.
http://prntscr.com/6lzjkd
I figure out this.Main Problem I push the segue to tabbar controller.And I fixed it with this code.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
ApiClass *apiClass = [self.customerCards objectAtIndex:indexPath.row];
UITabBarController *tabBarController = [segue destinationViewController];
CustomerDetailViewController *customerDetailViewController = (CustomerDetailViewController *)[[tabBarController viewControllers]objectAtIndex:0];
customerDetailViewController.mid = apiClass.mid;
}
It is trying to execute the method setMid:, but it can't find that one. Did you set the property mid as readwrite?

Sending a info to detailview from UICollectionView is not working?

I think i didnt explain well in the title, heres the problem, I have a collection view that is supplying from a json, but when I go to the detail it crashes, i think the problem is in this part of the code when I send the info to the detail:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier]isEqualToString:#"detailView"]) {
NSIndexPath *myIndexPath = [self.collectionView indexPathsForSelectedItems];
int row = [myIndexPath row];
MenuDetailViewController *menu = [segue destinationViewController];
EntryJson *entry = [[InfoWeb sharedInstance] entryAtIndex:row];
menu.galeriademo = entry.imagenes;
menu.DetailModalprim = #[entry.title == nil ? #"" : entry.title,
entry.date == nil ? #"" : entry.date,
entry.desc == nil ? #"" : entry.desc,
entry.mainimage == nil ? #"" : entry.mainimage,
entry.seccion == nil ? #"" : entry.seccion];
}
}
In a tableview the IndexPath would be like: NSIndexPath *myIndexPath = [self.collectionView indexpathforselectedRow];
I had a tableview working like this and it was fine but when I change to a collection view i had this problem. The crash log is the next:
2014-03-07 12:41:00.696 CMT[28640:70b] -[__NSArrayI row]: unrecognized selector sent to instance 0xc34d180
2014-03-07 12:41:00.698 CMT[28640:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI row]: unrecognized selector sent to instance 0xc34d180'
So I need your help! Thanks!
indexPathsForSelectedItems returns an NSarray, not an NSIndexPath
NSIndexPath *myIndexPath = [self.collectionView indexPathsForSelectedItems];
should be
NSArray *myIndexPaths = [self.collectionView indexPathsForSelectedItems];
NSIndexPath *myIndexPath = [myIndexPahts objectAtIndex:0];

View Controllers giving an error when creating a segue

I have a navigation controller and the first VC modals into the second one fine. I pressed ctrl+button and dragged it over, all works fine.
I am doing a second segue from the first VC (again) and this time its another button, I am ctrl+button and dragging it to the new VC and I get an USELESS error in XCODE -
2014-03-04 11:57:21.340 OutTonight[3173:60b] -[SettingsViewController
setDealdetail:]: unrecognized selector sent to instance 0x16e686d0
2014-03-04 11:57:21.342 OutTonight[3173:60b] * Terminating app due
to uncaught exception 'NSInvalidArgumentException', reason:
'-[SettingsViewController setDealdetail:]: unrecognized selector sent
to instance 0x16e686d0'
* First throw call stack:
Here is my prepareforseguecode
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableview indexPathForSelectedRow];
DealViewController *detailView = (DealViewController *)segue.destinationViewController;
detailView.dealdetail = [self.allcontent objectAtIndex:indexPath.row];
detailView.dealpostcode = [self.allpostode objectAtIndex:indexPath.row];
detailView.dealvenuename = [self.allname objectAtIndex:indexPath.row];
detailView.dealaddress = [self.alladdress objectAtIndex:indexPath.row];
detailView.dealaddress2 = [self.alladdress2 objectAtIndex:indexPath.row];
detailView.deallat = [self.alllat objectAtIndex:indexPath.row];
detailView.deallng = [self.alllong objectAtIndex:indexPath.row];
detailView.userlatitude = [[NSUserDefaults standardUserDefaults] objectForKey:#"UserLatitude"];
detailView.userlongitude = [[NSUserDefaults standardUserDefaults] objectForKey:#"UserLongitude"];
}
Any ideas?
I assume you have done something in -prepareForSegue: for the original segue? In which case, you need to make sure you are checking which segue it is in -prepareForSegue:, and doing the correct thing for each one.
Edit:
To expand on my answer, I guess you are using segue.destinationViewController, and calling setDealdetail: on it. This probably worked fine for your initial segue, because the destinationViewController responded to that message, but, the destination for the new segue doesn't. You need to check which segue is being performed. Using [segue.identifier isEqualToString:MySegueIdentifierString];
Edit 2 (after posting code):
Ok, you need to check which segue is being performed in your -prepareForSegue:. Something like this:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:SegueToDealViewControllerIdentifier]) {
NSIndexPath *indexPath = [self.tableview indexPathForSelectedRow];
DealViewController *detailView = (DealViewController *)segue.destinationViewController;
detailView.dealdetail = [self.allcontent objectAtIndex:indexPath.row];
detailView.dealpostcode = [self.allpostode objectAtIndex:indexPath.row];
detailView.dealvenuename = [self.allname objectAtIndex:indexPath.row];
detailView.dealaddress = [self.alladdress objectAtIndex:indexPath.row];
detailView.dealaddress2 = [self.alladdress2 objectAtIndex:indexPath.row];
detailView.deallat = [self.alllat objectAtIndex:indexPath.row];
detailView.deallng = [self.alllong objectAtIndex:indexPath.row];
detailView.userlatitude = [[NSUserDefaults standardUserDefaults] objectForKey:#"UserLatitude"];
detailView.userlongitude = [[NSUserDefaults standardUserDefaults] objectForKey:#"UserLongitude"];
}
}
Where SegueToDealViewControllerIdentifier is the segue identifier for the original segue.

Add row to UITableViewController from child

I have UIViewController that performs a login check with the code below, and a UITableViewController as its parent controller. I'm trying to add another row to the UITableViewController after switching back to it, however I'm getting the following error:
[UINavigationController insertNewObject:]: unrecognized selector sent to instance 0x14de164d0
2014-03-08 17:00:27.379 MyApp[2562:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController insertNewObject:]: unrecognized selector sent to instance 0x14de164d0'
-
if(loginSuccess)
{
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController performSelector:#selector(insertNewObject:) withObject:#"Another Row"];
}
The method definition of insertNewObject is:
- (void)insertNewObject:(NSString *)name
{
if (!_objects) {
_objects = [[NSMutableArray alloc] init];
}
[_objects insertObject:name atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
Can someone help me with what I'm doing wrong?
You're calling insertNewObject on a UINavigationController not your UITableViewController.
Try creating a property on your UIViewController that points to the original TableViewController and calling it through the property. Or calling it when the TableViewController reappears.

how to pass value from tableviewController to uiviewcontroller after selecting the row [duplicate]

This question already has answers here:
Passing data between view controllers
(45 answers)
Closed 9 years ago.
I have the code below : where Cell new is Custom cell which has array which has object at index when user selects a row which has to be transfered to anothe uiviewcontroller to display that msg But I am unable to do that.
by doing this : I get an error
Incompatible pointer types assigning to 'NSString *' from 'UILabel *'
VC2.DisplayMsg.text = cell.textLabel;
displayMsg is a label in uiviewcontroller where the text has to be displayed.Where Am I going wrong?
Please help me out or suggest any other way to transfer value from navigational uitableviwController to another viewcontroller on selecting the row and displaying the message in that uiviewController.Please help me out.I appreciate a great deal.
Thanks in Advance.
Complete code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Cellnew *cell = [array objectAtIndex:indexPath.row];
ViewControllerDisplayMsg *VC2 = [[ViewControllerDisplayMsg alloc] init];
VC2.DisplayMsgtext = cell.textLabel.text;
[self performSegueWithIdentifier:#"displayMsgSegueIdentifier" sender:self];
}
The error :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString textLabel]: unrecognized selector sent to instance
You should define a NSString property in other viewController and first assign the value from your table to this string and finally in your viewController's viewDidLoad method you can assign this string to the label text. It is good idea to define your Other Controller as a property to your FirstController.
You should keep the graphical elements updated within the class because this corresponding class or controller is responsible to show the graphical elements & values.
YourTableViewController.h
#class SecondViewController;
#property(strong,nonatomic)SecondViewController secondVC;
YourTableViewController.m
self.secondVC=[SecondViewContrlller alloc]initwithNibName:#"SecondViewController" bundle:nil];
self.secondVC.stringValue= cell.textLabel.text;
YourOtherViewController.h
#property(strong,nonatomic)NSString *stringValue;
YourOtherViewController.m
-(void)viewDidLoad{
self.displayMsg.text=self.stringValue;
[super viewDidLoad];
}
Take a NSString property in your UIViewController, say DisplayMsg:
then in didSelectRowAtIndexPath method:
VC2.DisplayMsg=cell.textLabel.text;
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:#"YOUR_SEGUE_NAME_HERE"])
{
// Get reference to the destination view controller
YourViewController *vc = [segue destinationViewController];
// Pass any objects to the view controller here, like...
[vc setMyObjectHere:object];
}
}
This code will help you

Resources