There is often a need to encapsulate your own modules or open classes into static libraries to provide convenient calls to others.
But when you need to use a lot of xib, pictures, audio or other resource files in your module, you can't add them to the static library. At this point, some resource files need to be encapsulated. Bundle file. Well, the packaged stuff should contain three types of files:
1: Open header file (contains full call notes)
2: Static library file suffix named. A
3:bundle file for storing various resource files.
So the rest is simple: here is a specific package of bundle files (in fact, very simple)
First step: Create a bundle project
Select the bundle file type and create the project.
Step Two: Modify buildsetting Related Settings
1:base SDK modified to iOS6 or other existing iOS SDK versions
2:architectures modified to ARMv7 armv7s
Step Three: Add the resource file you want to add
Fourth Step: Build (This does not require a certificate and can be compiled successfully)
This generates your own bundle.
When called, the help needs to be referenced to the project in the line, as follows:
Introduction method in the program:
1 get the resources in the bundle2 3NSString * Bundlepath = [[NSBundle mainbundle] Pathforresource: @"Mybundle"OfType: @"Bundle"];4NSBundle *resourcebundle =[NSBundle Bundlewithpath:bundlepath];5Uiviewcontroller *VC = [[Uiviewcontroller alloc] Initwithnibname:@"Vc_name"Bundle:resourcebundle];6 7 picture Gets the resources in the bundle8 9Uiimageview *imgview=[[uiimageview Alloc] Initwithframe:cgrectmake ( -, -, -, -)];TenUIImage *image = [UIImage imagenamed:@"mybundle.bundle/img_collect_success"]; One [Imgview setimage:image]; A - or - theUiimageview *imgview=[[uiimageview Alloc] Initwithframe:cgrectmake ( -, -, -, -)]; -NSString *imgpath= [Bundlepath stringbyappendingpathcomponent:@"Img_collect_success.png"]; -UIImage *image_1=[UIImage Imagewithcontentsoffile:imgpath]; - [Imgview setimage:image_1]; + - of course, it can be written as a precompiled statement: + #defineMybundle_name @ "Mybundle.bundle" A #defineMybundle_path [[[NSBundle Mainbundle] ResourcePath] stringbyappendingpathcomponent:mybundle_name] at #defineMybundle [NSBundle Bundlewithpath:mybundle_path]
If you want to be called in a non-mainbundle place. Then you need to load this bundle extra
Creation and use of bundle files