Problem with pushViewController

Discussion in 'iOS Development' started by ipodgreatmaster, Feb 25, 2009.

  1. ipodgreatmaster

    ipodgreatmaster Member

    Joined:
    Feb 20, 2008
    Messages:
    186
    Likes Received:
    0
    Device:
    4G iPod touch
    hello. I am making a new app and in one view named about. This view named About is in About.xib and is controlled by AboutController. In About view there is a bar button item. I want that when i clic in that button the SpecialThanksTo.xib which has a controller named SpecialThanksController are loaded. So in aboutcontroller.h i put this:

    Code:
    #import <UIKit/UIKit.h>
    
    
    @interface AboutController : UIViewController {
    
    }
    
    -(IBAction)showSpecialThanks:(id)sender;
    
    @end

    In aboutcontroller.m i have this:

    Code:
    #import "AboutController.h"
    #import "SpecialThanksController.h"
    
    
    @implementation AboutController
    
    
    -(IBAction)showSpecialThanks:(id)sender{
    	SpecialThanksController *varSpecialThanks = [[SpecialThanksController alloc] initWithNibName:@"SpecialThanksTo" bundle:nil];
    	[[self navigationController] pushViewController:varSpecialThanks animated:YES];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
        // Release anything that's not essential, such as cached data
    }
    
    
    - (void)dealloc {
        [super dealloc];
    }
    
    
    @end
    
    In appdelegate.h i make a iboutlet uinavigationcontroller *navigationController;

    and a property for navigationController.


    In appdelegate.m i have synthesize navigationController.

    This have worked perfectlyin another xib of the project but i dont know why in this case it do not work. In console appears:

    Code:
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIViewController showSpecialThanks:]: unrecognized selector sent to instance 0x2625e60'
    If you need more information to solve the problem just ask me.

    Please someone help me
    Thanks and sorry by my bad english
  2. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    thats because to pop and push view controllers you have to be using a sub class of UINavigationController
  3. ipodgreatmaster

    ipodgreatmaster Member

    Joined:
    Feb 20, 2008
    Messages:
    186
    Likes Received:
    0
    Device:
    4G iPod touch
    But why it works with my other view? Its the same as the one im using.

    PS: how do i make a sub class of uinavigationcontroller
  4. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    hmm there must be a way to do it with UIViewControllers as well anyway to make a sub class o UINavigationController either use a navigation based project or go file, new file the UINavigationController sub class
  5. ipodgreatmaster

    ipodgreatmaster Member

    Joined:
    Feb 20, 2008
    Messages:
    186
    Likes Received:
    0
    Device:
    4G iPod touch
    I have compared my method with one in internet and it is all the same. That project works perfect. Mine dont
  6. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    are you able to upload this project somewhere for me to look at it ?
  7. ipodgreatmaster

    ipodgreatmaster Member

    Joined:
    Feb 20, 2008
    Messages:
    186
    Likes Received:
    0
    Device:
    4G iPod touch
  8. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    I meant your project! I can't fix your project by looking at someone elses.
  9. ipodgreatmaster

    ipodgreatmaster Member

    Joined:
    Feb 20, 2008
    Messages:
    186
    Likes Received:
    0
    Device:
    4G iPod touch
    I cant. Sorry.

    I try to put the button were everything works and put every code of that works perfectly.
    But in the other xib doesnt work!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    And i need it in that xib urgently!!!!!!!!!!!!!!!!!!!!!!!!

    Thanks
  10. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    You should never subclass UINavigationController. Apple state that right in their docs. And, I agree that there is no reason to ever subclass the UINavigationController.

    As far as your problem goes, we can't help without actually seeing how you've set everything up.

Share This Page