Note that there are some explanatory texts on larger screens.

plurals
  1. POUITabBarController and UIViewController Transition
    primarykey
    data
    text
    <p>I have a UITabBarController that loads 2 UIViewControllers: a map and a table. When a tabBarItem is clicked, I catch the event and set some properties on the destination view:</p> <pre><code>- (void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if([viewController.tabBarItem.title isEqualToString:@"Map"]) { MapViewController *MVC = [tabBarController.childViewControllers objectAtIndex: viewController.tabBarController.selectedIndex]; MVC.billboards = self.billboards; MVC.rangeMaxWidth = self.rangeMaxWidth; MVC.rangeMaxHeight = self.rangeMaxHeight; MVC.APIRoot = self.APIRoot; } } </code></pre> <p>Now the code above works great; however, when I try to do the same thing for my table view I get a cryptic error. Here is the full code:</p> <pre><code>- (void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if([viewController.tabBarItem.title isEqualToString:@"Map"]) { MapViewController *MVC = [tabBarController.childViewControllers objectAtIndex: viewController.tabBarController.selectedIndex]; MVC.billboards = self.billboards; MVC.rangeMaxWidth = self.rangeMaxWidth; MVC.rangeMaxHeight = self.rangeMaxHeight; MVC.APIRoot = self.APIRoot; } else if ([viewController.tabBarItem.title isEqualToString:@"Manage"]) { ManageBillboardsController *MBC = [tabBarController.childViewControllers objectAtIndex: viewController.tabBarController.selectedIndex]; MBC.aNumber = [[NSNumber alloc] initWithInt:3]; } } </code></pre> <p>-[UINavigationController setANumber:]: unrecognized selector sent to instance 0x9e91400 2013-06-27 15:09:18.624 Billboard[3269:c07] <em>*</em> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setANumber:]: unrecognized selector sent to instance 0x9e91400'</p> <p>I think I've double checked everything and everything seems to be the same for both views. So I don't understand why this works for the map view but not for the table.</p> <p>Thanks in advance.</p> <p><strong>* SOLUTION *</strong></p> <pre><code>- (void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if([viewController.tabBarItem.title isEqualToString:@"Map"]) { MapViewController *MVC = [tabBarController.childViewControllers objectAtIndex: viewController.tabBarController.selectedIndex]; MVC.billboards = self.billboards; MVC.rangeMaxWidth = self.rangeMaxWidth; MVC.rangeMaxHeight = self.rangeMaxHeight; MVC.APIRoot = self.APIRoot; } else if ([viewController.tabBarItem.title isEqualToString:@"Manage"]) { UINavigationController *NC = [tabBarController.childViewControllers objectAtIndex: viewController.tabBarController.selectedIndex]; NSArray *controllers = [NC childViewControllers]; for(id item in controllers){ ManageBillboardsController *MBC = item; MBC.aNumber = [[NSNumber alloc] initWithInt:3]; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload