您好,登錄后才能下訂單哦!
1. 新建一個靜態庫工程bundle
2. 新建一個Viewcontroller
3. 新建一個Target Bundle并指定SDK為iOS, 并將TestViewController.xib加到Copy Bundle Resouce
5. bundle 代碼如下
#import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。