Exception with setViewController

Discussion in 'iOS Programming' started by bboyjayz, Apr 29, 2009.

  1. macrumors member

    Joined:
    Mar 20, 2009
    #1
    hi,
    i try for 3 days, to change my viewController added into the MainWindow, with another viewController, i've already done that before, and it work very well.
    Whereas, for the app I try to make now, when i push the button to change the view, it doesn't work, and my application send me an exception :

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString setViewController:]: unrecognized selector sent to instance 0x7160'

    Do you know what can cause this error ?
    Thank youuu
     
  2. macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #2
    Are these view controllers part of a navigation controller?

    Do you have an instance variable named viewController?

    Does that instance variable have a setter named setViewController: ?
     
  3. thread starter macrumors member

    Joined:
    Mar 20, 2009
    #3
    my application is a simple Window Base Application (no naviguation bar or other), I want to swith my View with a simple UIButton.

    I have a viewController instance on my myApplicationAppDelegate ..
    And i don't have created a setViewController methodS...:s
     
  4. macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #4
    Well, the UIButton is going to be part of a view, so you are going to switch *that* view to something else (another button in the new view)?

    What kind of a switch are you talking about? Animation? You might want to just use a navigation controller.
     
  5. thread starter macrumors member

    Joined:
    Mar 20, 2009
    #5
    Yes my switch is an animation, and, i've a view, which has a UIButton, and when i touch it, a new view appear
     
  6. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #6
    view != view controller

    If you want to change views, make a new view (rather than a new view controller), and add that view to the current view controller.

    If you want to change view controllers, you need to use a navigation controller or tab bar controller.
     
  7. thread starter macrumors member

    Joined:
    Mar 20, 2009
    #7
    Usualy, i change my ViewController, without Naviguation Bar or Other, i don't know if it's the best way .... but it works. ..
    It's just for this project, it doesn't work and i don't know why...
    Even if in my First ViewController, I create a view same than the View of my Second ViewController, i've se same error...
     
  8. thread starter macrumors member

    Joined:
    Mar 20, 2009
    #8
    i'm just realizing on,e thing: me app is a game, when, during the game, i ask for a new Game, i removeFromSuperView of my delegate.window the current view, i create a new instance of myGameViewController, and add the View of this of my window...first point: it works.

    Seconde point, the bad one: when i'm on the menuViewController, and i want to change my viewController, i use the same peace of code, and i've the exception.... wird. ..
     
  9. thread starter macrumors member

    Joined:
    Mar 20, 2009
    #9
    Magic: IT'S WORK :) thank you for your help, copy past my own code ... and it's work...lame
     

Share This Page