开发者

Switching Views in iPhone SDK?

How come this won't switch views for me? When I click the button it does nothing...

-(IBAction)howtoplayButtonClicked{
    howToPlayViewController = [[HowToPlayViewController alloc] initWithNibName:@"HowToPlayViewController" bu开发者_StackOverflow社区ndle:nil];
    [self.navigationController pushViewController:howToPlayViewController animated:YES];
    [HowToPlayViewController release];

}

in the .h file I have this...

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

@interface PopToItViewController : UIViewController {

    HowToPlayViewController *howToPlayViewController;

}

-(IBAction)howtoplayButtonClicked;

@end


Your action method...

-(IBAction)howtoplayButtonClicked;

... should look like this:

-(IBAction)howtoplayButtonClicked:(id) sender;

In it's improper form it might not be called. If correcting the form does not work, you should:

  1. Put a breakpoint or log statement in the method to see if it ever gets called. If it does not check you IBConnections to make sure the button is wired to the method.
  2. You don't need howToPlayViewController set as property if your initializing it from nib and then releasing it. Generally you would only use a property if you wanted to wire it up in Interface Builder in which case it should be defined like so:

    IBOutlet HowToPlayViewController *howToPlayViewController;


For starters, this is wrong:

[HowToPlayViewController release];

It should be:

[howToPlayViewController release];

I don't know what sending a release message to a Class does.


Make sure self.navigationController!=nil


Set initWithNibName:nil" and let the view controller do the rest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜