![](/img/trans.png)
[英]Navigation controller navigationItems doesn't show up as i expected
[英]navigation controller doesn't show up the view
PS:请不要建议我采用应用程序委托方式,因为我会在应用程序视图的中间使用它。 感谢名单。
我尝试使用UINavigationController
来显示类似settings
应用程序的UITableView
。 因此,我正在尝试逐步进行。 到目前为止,我试图显示导航堆栈中视图控制器中包含的视图。 但是我在某处缺少什么。
这是我的相关代码:
.h file:
@interface ViewController : UINavigationController{
UINavigationController *navigationController;
UIViewController *viewController;
}
@property(nonatomic, strong)IBOutlet UINavigationController *navigationController;
@property(nonatomic, strong)IBOutlet UIViewController *viewController;
@end
.m文件:
@implementation ViewController
@synthesize navigationController;
@synthesize viewController;
- (void)viewDidLoad
{
[super viewDidLoad];
//Do any additional setup after loading the view, typically from a nib.
self.viewController = [[UIViewController alloc]init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.navigationController.view addSubview:self.viewController.view];
}
**The xib file:**
运行该应用程序时,我期望看到蓝色视图,但是我看到的只是默认的蓝色导航栏,甚至没有“ Root View Controller”标题消息。
如果从IB连接UI,请尝试删除这些行(删除alloc,init)
// self.viewController = [[UIViewController alloc]init];
// self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
// [self.navigationController.view addSubview:self.viewController.view];
此链接应为您提供帮助。 您可能想通过此过程更好地了解您遇到的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.