iOS静态库结合Bundle隐藏代码,对外接口整理-创新互联
1. 新建一个静态库工程bundle


2. 新建一个Viewcontroller

3. 新建一个Target Bundle并指定SDK为iOS, 并将TestViewController.xib加到Copy Bundle Resouce


5. bundle 代码如下
#import#import @interface bundle : NSObject - (void) addViewController:(UIView *)view; @end #import "bundle.h" #import "TestViewController.h" @implementation bundle - (void) addViewController:(UIView *)view { NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"Test" withExtension:@"bundle"]]; TestViewController *testCtrl = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:bundle]; [view addSubview:testCtrl.view]; } @end
6. 新建一个工程TestBundle, 把libbundle.a,Test.bundle拖入到工程中,然后调用即可

#import "ViewController.h"
#import "bundle.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
bundle * addView = [[bundle alloc] init];
[addView addViewController:self.view];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享标题:iOS静态库结合Bundle隐藏代码,对外接口整理-创新互联
文章位置:http://www.jxjierui.cn/article/ecicp.html


咨询
建站咨询
