Can't make my button switch views.

Discussion in 'iOS Programming' started by mrl4214, Sep 5, 2010.

  1. mrl4214 macrumors newbie

    Joined:
    Sep 5, 2010
    #1
    I created a button which is supposed to launch a view.. heres what I have so far:

    Code:
    	SocialwebTwitter *myView = [[SocialwebTwitter alloc] initWithNibName:@"SocialwebTwitter" bundle:[NSBundle mainBundle]];
    	NSLog(@"Waiting!!");
    		[self.navigationController pushViewController:myView animated:YES];
    	NSLog(@"Finshed!");
    	[myView release];

    All of the logs get printed out on the console however the view never opens or gives any indication that anything occurred. I know the button is working but it seems that its either in the code or in some aspect of the interface builder.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Are you pushing a UIViewController or a UIView onto the navController?
     
  3. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #3
    Do you have a Navigation Controller initialized in your app delegate.
     
  4. mrl4214 thread starter macrumors newbie

    Joined:
    Sep 5, 2010
    #4
    I dont think I do... I am new to iOS development so I don't know how to do that.
     
  5. mrl4214 thread starter macrumors newbie

    Joined:
    Sep 5, 2010
    #5
    Well I was actually trying to push UIViewController to another UIViewController. IF thats the wrong way to go about it I will need some help ;)


    -Thanks!
     
  6. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #6
    First you will need to instantiate a UINaviationController by alloc/initWithRootViewController from within your app Delegate.

    Next replace the default view with the newly created navigation controller.


    Then within your rootView Controller push the other view controller on to the navigation stack.
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    No, that's the right way (other than needing a navController). But without knowing what class SocialwebTwitter is a subclass of and you're variable being called myView, I just wanted to be sure you were pushing the right kind of object.
     

Share This Page