从UIViewController呈现UINavigationController

Bip*_*ung 0 uiviewcontroller uinavigationcontroller ios

CurrentViewController.h

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

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

@end
Run Code Online (Sandbox Code Playgroud)

CurrentViewController.m

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


}
/* ......... */
Run Code Online (Sandbox Code Playgroud)

nextNavViewController.h

#import <UIKit/UIKit.h>

@interface nextNavViewController : UINavigationController

@end
Run Code Online (Sandbox Code Playgroud)

我有"nextNavViewController.xib",其中包含一个表,一些按钮和自定义导航栏.我希望加载此接口,但它加载空白屏幕的空白导航栏.

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

Rui*_*res 5

有几件事:

1)小心你的课程名称.确保它们符合Objective-c标准

2)你不需要分类a UINavigationController.如果你想获得a的一些功能UINavigationController,只需:

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

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

[self presentViewController:myNavigation animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)