我在我的应用中使用了UINavigationController
,由于某种原因,它不允许我将页面切换到名为CompanyView的third xib
。它从第一个切换到第二个但不是第三个。我可能做错了但是如果有人能查看我的代码会很棒。我相信我按钮设置正确。
以下是我不会更改视图的.h file
xib
:
#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
答案 0 :(得分:0)
尝试以这种方式初始化您的公司视图。
CompanyView *companyView = [[CompanyView alloc] initWithNibName:@"CompanyView" bundle:nil];
答案 1 :(得分:0)
这就是我设置它的方式:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
CategoryPresetViewController *controller = [[CategoryPresetViewController alloc] initWithPVCDelegate:avc];
controller.title = [[factoryCategoryNameArray objectAtIndex:indexPath.row] retain];
if (controller != nil){
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
也许它可以帮到你