我在我的應用中使用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