【问题标题】:Present UINavigationController from UIViewController从 UIViewController 呈现 UINavigationController
【发布时间】:2012-12-11 07:10:18
【问题描述】:

CurrentViewController.h

#import <UIKit/UIKit.h>
#import "nextNavViewController.h"
@interface CurrentViewController : UIViewController 

{
nextNavViewController *contr;
}
- (IBAction)showNavView:(id)sender;

@end

CurrentViewController.m

/*..........*/
- (IBAction)showNavView:(id)sender {
    contr = [[nextNavViewController alloc]initWithNibName:@"nextNavViewController"bundle:nil];
    [self presentViewController: contr animated:YES completion:nil];


}
/* ......... */

nextNavViewController.h

#import <UIKit/UIKit.h>

@interface nextNavViewController : UINavigationController

@end

我有“nextNavViewController.xib”,其中包含一个表格、一些按钮和自定义导航栏。我希望加载此界面,但它会加载带有空白屏幕的空白导航栏。

我正在做的事情可能吗?我要怎么做才能加载自定义界面??

【问题讨论】:

  • 这个导航控制器有根视图控制器吗?
  • 很难看到有人继承 UINavigationController。您应该在 XIB 中删除一个,并在代码中为推送初始化一个。
  • @rdelmar 我必须在哪里编写什么代码才能将根视图控制器添加到 NextNavViewController。
  • @CodaFi 我不明白你想说什么。

标签: ios uiviewcontroller uinavigationcontroller


【解决方案1】:

有几点:

1) 注意你的类名。确保他们关注objective-c standards

2) 您不需要对UINavigationController 进行子类化。如果您想获得UINavigationController 的一些功能,只需:

contr = [[nextNavViewController alloc]initWithNibName:@"nextNavViewController"bundle:nil];

UINavigationController *myNavigation = [[UINavigationController alloc] initWithRootViewController:contr];

[self presentViewController:myNavigation animated:YES completion:nil];

【讨论】:

  • 杰克,我的孩子,一如既往的出色。 +1 用于解释我在 cmets 中无法解释的内容。
猜你喜欢
  • 2014-07-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多