我在我的应用中使用UINavigationController
,出于某种原因,它不允许我将页面切换到名为CompanyView的third xib
。它从第一到第二,但不是第二个第三。我可能做错了,但如果有人可以查看我的代码,那将是很棒的。我相信按钮设置正确。 这里是我.h file
为xib
不会改变的观点:使用UINavigationController导航到另一个视图
#import <UIKit/UIKit.h>
#import "CompanyView.h"
@interface MenuView : UIViewController
-(IBAction)btnClicked:(id)sender;
@end
这里是我的.m file
代码:
#import "MenuView.h"
@implementation MenuView
-(IBAction)btnClicked:(id)sender {
CompanyView * companyView = [[CompanyView alloc] init];
companyView.title = @"Company";
[self.navigationController pushViewController:companyView animated:YES];
[companyView release];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
嗯...它仍然没有切换。是否有一段代码应该添加到我的CompanyView.h和.m文件中? – Maple 2012-03-08 21:54:32