Note that there are some explanatory texts on larger screens.

plurals
  1. POPushing ViewController gives NSInvalidArgumentException
    primarykey
    data
    text
    <p>I'm a newbie iOS developer, recently developed several Android apps, but I'm not familiar with iOS jargon. Let me explain my problem.</p> <p>I want to use two different <code>UIViewController</code>. I've created <code>.h</code> and <code>.m</code> files for both controller. My plan is to push the secont view controller on top of the first view controller five seconds after the first view controller appears on the screen. I mean the first view controller is something like splash screen or similar.</p> <p>Here is my contribution. In the first view controller, I defined (one of them implemented of course) these two method:</p> <pre><code>-(void) pushSecondController { SecondViewController *secondController = [[SecondViewController alloc] initWithNibName: nil bundle: NULL]; [self.navigationController pushViewController: secondController animated: YES]; } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self performSelector: @selector(pushViewController:animated:) withObject: nil afterDelay: 5.0f]; } </code></pre> <p>And the second view controller looks like this:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.title = @"Second Controller"; } </code></pre> <p>I've changed only <code>viewDidLoad</code> method. When I ran the simulator, first view controller worked well and waiting 5 seconds and crashed. Output looks like:</p> <pre><code>2012-08-24 10:46:34.104 NavApplication[20355:f803] -[ViewController pushViewController:]: unrecognized selector sent to instance 0x6e7f780 2012-08-24 10:46:34.107 NavApplication[20355:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController pushViewController:]: unrecognized selector sent to instance 0x6e7f780' </code></pre> <p>Let me ask one more question: I know there are differences between <code>methodName</code> and <code>methodName:</code>. Can anyone explain what's difference?</p> <p>Any help would be appreciated.</p> <p><strong>UPDATE:</strong></p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; self.window.rootViewController = self.viewController; self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; [self.window makeKeyAndVisible]; [self.window addSubview: self.navigationController.view]; return YES; } </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.
 

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