What are the benefits of using Storyboards instead of xib files in iOS programming?

A Storyboard is: A container for all your Scenes (View Controllers, Nav Controllers, TabBar Controllers, etc) A manager of connections and transitions between these scenes (these are called Segues) A nice way to manage how different controllers talk to each other Storyboards give you a complete look at the flow of your application that you … Read more

Marking some XIB/Storyboard strings as not localizable

I add a note “DNL” to the “Comment for Localizer” field in the identity tab. Then, I run this command to automatically remove all of those elements from the XLIFF: xmlstarlet ed -d “//*[contains(text(), ‘Note = \”DNL\”‘)]/..” en.xliff > out.xliff Basically, it’s using xmlstarlet (which can be downloaded via homebrew) to find all elements that … Read more

Manually loading a different localized nib in iOs

So, just like I said in the edit, this is what I found as a solution: NSString* path= [[NSBundle mainBundle] pathForResource:@”de” ofType:@”lproj”]; NSBundle* languageBundle = [NSBundle bundleWithPath:path]; self.currentController = [[newClass alloc] initWithNibName:@”CustomController” bundle:languageBundle]; And if you need to load a text into a localized label NSString* path= [[NSBundle mainBundle] pathForResource:[[[NSUserDefaults standardUserDefaults] objectForKey:@”AppleLanguages”] objectAtIndex:0] ofType:@”lproj”]; NSBundle* … Read more

Xcode 4 .xib Create iPad Version

This worked for me: Make a copy of the .xib in the Finder. Open the copied file in a text editor. Change “com.apple.InterfaceBuilder3.CocoaTouch.XIB” to “com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB”. Change all instances of “IBCocoaTouchFramework” to “IBIPadFramework”. Search for sizes like {480, 320} and edit them. Or just reopen the file in Xcode and use the GUI to resize items … Read more

Assign xib to the UIView in Swift

for Swift 4 extension UIView { class func loadFromNibNamed(nibNamed: String, bundle: Bundle? = nil) -> UIView? { return UINib( nibName: nibNamed, bundle: bundle ).instantiate(withOwner: nil, options: nil)[0] as? UIView } } for Swift 3 You could create an extension on UIView: extension UIView { class func loadFromNibNamed(nibNamed: String, bundle: NSBundle? = nil) -> UIView? { … Read more

Correct way to load a Nib for a UIView subclass

MyViewClass *myViewObject = [[[NSBundle mainBundle] loadNibNamed:@”MyViewClassNib” owner:self options:nil] objectAtIndex:0] I’m using this to initialise the reusable custom views I have. Note that you can use “firstObject” at the end there, it’s a little cleaner. “firstObject” is a handy method for NSArray and NSMutableArray. Here’s a typical example, of loading a xib to use as a … Read more