views:

319

answers:

2

Hello, here is a iPhone programming beginner's question: How do I get to another view by pressing a button in my main view?

I have the following function which is executed when I press a button, and debugging it, he passes there, but my "Warning" view does not show up:

-(IBAction) showWarningView:(id)sender

{

    if(self.showWarning == nil){
     WarningViewController *nextView = [[WarningViewController alloc] initWithNibName:@"Warning" bundle:[NSBundle mainBundle]];
     self.showWarning = nextView;
     [nextView release];
    }
    [self.navigationController pushViewController:self.showWarning animated:YES];

}

My main RootViewController looks like this:

#import <UIKit/UIKit.h>
#import "WarningViewController.h"

@interface RootViewController : UIViewController {
    IBOutlet UIButton *button1;
    WarningViewController *showWarning;

}
@property(nonatomic,retain) WarningViewController *showWarning;

-(IBAction) showWarningView:(id)sender;

@end

I am using the navigation control of a UITableViewController but what do I have to use to just simply show my other view when I press a button in a view-based application? Thanks a lot!

A: 

edited

if you're using the navigation control of a UITableViewController, you probably have to push the view in you tableviewcontrollers navigation controller this means you have pass the navigation controller of your tableviewcontroller on to your viewcontroller, then you just push it

e.g.

[self.tableViewControllersNavigationController pushViewController:self.showWarning animated:YES];

(for passing the tableViewController's navigationController on, you might have to create a delegate pattern)

gabtub
Yeah, isn't that we he wrote above anyway? Seems like he actually does not want to use that...
Dimitri Wetzel
@dimitri ye, should've read more attentively, edited now
gabtub
A: 

Does the title in your navigation bar change? Maybe you don't have a UIView associated with your UIViewController inside your Interface Builder file.

Leo