简体   繁体   English

如何使用Xib在导航控制器中加载视图

[英]How to load a view inside a navigation controller using xib

I'm trying to load a viewcontroller on tap of a button which is present in the xib file. 我正在尝试在xib文件中存在的按钮的点击上加载viewcontroller。 The viewcontroller is embedded in an navigation controller. ViewController嵌入在导航控制器中。

Right now i'm doing this ie,inside the IBAction() method of xib button. 现在,我正在执行此操作,即在xib按钮的IBAction()方法内部。

[self showViewController:viewcontroller sender:self];

The navigation takes place with all the navigation bar items but no view is getting loaded. 导航与所有导航栏项目一起发生,但未加载任何视图。

Can anyone help me with this... 谁能帮我这个...

Thanks in advance 提前致谢

Write following function in your AppDelegate.m file: 在AppDelegate.m文件中编写以下函数:

-(void)loadViewController:(id)viewController
{
  UINavigationController *navigationController = appDelegate.container.centerViewController;

  NSArray *controllers = [NSArray arrayWithObject:viewController];
  navigationController.viewControllers = controllers;
}

and write following code in IBAction() of Button: 并在Button的IBAction()中编写以下代码:

- (IBAction)leftSideMenuButtonPressed:(id)sender 
{
   LoginViewController *loginController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];

   [self loadViewController:loginController];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用导航控制器加载Tabbar Controller Xib - How to load a tabbar controller xib using navigation controller 如何在不使用导航控制器或导航栏的情况下从Xib返回main.storyboard中的视图控制器? - How to return to view controller in main.storyboard from a xib without using navigation controller or navigation bar? 如何为视图控制器内部的Xib约束设置动画? - How to animate xib constraints inside a view controller? 如何在目标 c 中以编程方式使用 xib 在视图 controller 中创建导航栏? - How to create a navigation bar in a view controller using xib programmatically in objective c? 在xib文件中加载View控制器 - Load View controller in xib file 如何在另一个视图控制器中加载xib文件的视图 - How to load view of xib file in another view controller 在XIB中连接UIView并使用Story板中的View Controller加载它 - Connect UIView in XIB and load it using View Controller in the Story board 尝试子类化导航控制器,以便在iOS的横向模式下使用单独的.xib文件加载外部View Controller - Trying to subclass navigation controller in order to load external view Controller with separate .xib file in landscape mode in iOS 如何在一个视图控制器中将xib加载到两个容器视图中 - How to load xib into two Container Views within one view controller 如何在xib或情节提要上使用xib加载自定义视图 - how to load custom view with xib on a xib or storyboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM