Posts

Showing posts from July, 2012

Customize view using XIB

Image
This is the example of how to customize UITableViewCell using XIB. 1. Create your XIB: 2. Load XIB and create it as a view: 3. Done

Force using english localized if current localized does not exists

Create a class: CLocale.h #undef NSLocalizedString#define NSLocalizedString(key, comment) \ [CLocale localizedString:(key)] @interface CLocale : NSObject + (NSString*) localizedString:(NSString*)key; @end CLocale.m #import "CLocale.h" @implementation CLocale + (NSString*) localizedString:(NSString*)key { NSArray* languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]; NSString* currentLocale = [languages objectAtIndex:0]; NSString* localized = [[NSBundle mainBundle] localizedStringForKey:key value:@"" table:nil]; // if key and localized are same, also it is not english, // then force to use english language if ([localized compare:key] == NSOrderedSame && [currentLocale compare:@"en"] != NSOrderedSame) { NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]]; localized = NSLocalizedStringFro...