nsbundle

Using XIB/NIB files contained within downloaded bundles on iOS

和自甴很熟 提交于 2019-12-04 09:48:00
问题 On the face of it, this seems a very simple problem but for some reason I can't quite get it to work. I have a magazine-style app that downloads the data for each issue in the form of a zipped bundle. Once downloaded, and unpacked, the app successfully accesses the various files contained within the bundle as expected. These include JSON, PNG, JPG, video and so on. However, I also included a XIB file that contains the physical layout of the content in a series of UIViews and it is this file

NSBundle mainBundle pathForResource (maybe not the same problem)

扶醉桌前 提交于 2019-12-04 06:23:20
Problem : [NSBundle mainBundle] pathForResource returns null (0x0) I read a lot of posts on this topic, here is what I found: Make sure the file you are trying to get a path to, is in the project. To check, look in the project file list for the file, if it is not there, drag and drop it in. Check that the file your trying to load is being copied to the app. To do this, click on project under project files (blue bar with project name in it->Click on the target->Click on Build Phases->Click to expand the "copy Bundle Resources", and make sure your file is in it. If it is not, click the plus, and

Getting iPhone mainBundle Files

允我心安 提交于 2019-12-04 03:27:13
I dont know the exact code i need to retrieve all of the filenames of the resources in my iphone apps mainBundle. if i could have some kind of code like: NSArray *array = [[NSBundle mainBundle] getAllResourceFilenames]; it would be helpful. thanks inadvanced for any help! You should look at the SDK documentation for NSFileManager, but this will get you started: NSString *path = [[NSBundle mainBundle] resourcePath]; NSFileManager *fm = [NSFileManager defaultManager]; NSError *error = nil; NSArray *directoryAndFileNames = [fm contentsOfDirectoryAtPath:path error:&error]; You can get the

Impossible to load an image in xcassets on bundle

我与影子孤独终老i 提交于 2019-12-03 19:56:07
问题 I need to include images in a static library. I created a bundle and inserted in my images, the problem is that it seems to work if I include the images directly in the bundle, but stops working if I put in a xcassets file. I followed many guides and searched for a solution on this site. The most popular solution is to insert this line of code: [UIImage imageNamed:@"MyBundle.bundle/imageName"] but it seems not work for me any ideas? 回答1: There are two ways to solve this, If your app is still

OCUnit & NSBundle

空扰寡人 提交于 2019-12-03 18:45:30
问题 I created OCUnit test in concordance with "iPhone Development Guide". Here is the class I want to test: // myClass.h #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface myClass : NSObject { UIImage *image; } @property (readonly) UIImage *image; - (id)initWithIndex:(NSUInteger)aIndex; @end // myClass.m #import "myClass.m" @implementation myClass @synthesize image; - (id)init { return [self initWithIndex:0]; } - (id)initWithIndex:(NSUInteger)aIndex { if ((self = [super init]))

NSBundle pathForResource returns nil with subdirs

☆樱花仙子☆ 提交于 2019-12-03 17:41:45
问题 I have a bunch of directories and files in my app, for instance images/misc/mainmenu_background. . I'm running the following code in the "iPad Simulator 3.2": NSString *images = [[NSBundle mainBundle] pathForResource:@"images" ofType:nil]; NSString *images_misc = [[NSBundle mainBundle] pathForResource:@"images/misc" ofType:nil]; NSString *images_misc_file = [[NSBundle mainBundle] pathForResource:@"images/misc/mainmenu_background.png" ofType:nil]; After this call, images contains the path

Best way of loading images from application bundle

馋奶兔 提交于 2019-12-03 16:51:51
问题 What is the best way of loading images from the application main bundle. I am using [UIImage imageNamed: "image.png"]; But I have heard that this is not good in terms of memory usage and performance. Can anyone please give his/her feedback on it? My application reads lots of images from main bundle at launch time. I want to make this process as efficient as possible. Best Regards 回答1: If you want to try loading the images without caching, you can use: [[UIImage alloc] initWithContentsOfFile:@

Overriding preferred strings localization on the fly for testing

拟墨画扇 提交于 2019-12-03 13:56:30
问题 Using the Settings app in the iPhone simulator to switch languages is a PITA way of testing localization tweaks. I'm trying to figure out a way to switch localizations (en/fr/es/etc) on the fly in my app with a debug setting without restarting the app. NSBundle provides ways of requesting localized resources from an arbitrary localization, e.g. - (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)subpath forLocalization:(NSString *

How can I load an image from Assets.car (compiled version of xcassets) within an NSBundle? (without using CocoaPods)

青春壹個敷衍的年華 提交于 2019-12-03 13:48:31
问题 We're getting these kind of error messages: Could not load the "iconStatus" image referenced from a nib in the bundle with identifier "com.company.OurResourceBundle". Basically, we put a bunch of images in the xcassets folder ( which works for non-bundle loaded cases ). The xcassets and nib files are packed into a resource bundle. When the app launches, uiimageview in the nib file cannot load any images with the above error message. [UIImage imageNamed:@"OurResourceBundle.bundle/iconStatus"]

Could not find a storyboard named 'Main' in bundle NSBundle

此生再无相见时 提交于 2019-12-03 11:21:32
问题 during the progress of my app I decided to change from using a UIStoryboard to .xib file, and now I get the error: Could not find a storyboard named 'Main' in bundle NSBundle How can I fix this problem within the Simulator part of my app? 回答1: Remove the "Main storyboard file base name" or "UIMainStoryboardFile" Key from your info.plist file. 回答2: Click Your Story board then do step 2 and step 3 来源: https://stackoverflow.com/questions/25739477/could-not-find-a-storyboard-named-main-in-bundle