ViewController_iPad.xib vs ViewController~ipad.xib - ios

I am working on a tutorial and something interesting caught my attention. I just created a Single View Application Project and I noticed two .xib files, one named ViewController_iPhone.xib, one named ViewController_iPad.xib. In my projects, if I wanted different .xibs for iPhone and iPad I would use ViewController.xib for iPhone and ViewController~ipad.xib for iPad. I kind of understand that this may be a new naming convention, but can I use this naming convention event if I target older iOS versions?
Also this happens in xCode 4.6
Thank you.

I Think you might have come across universal applications on iOS , or might loading .xib files according to the device . Either way you should use ~ipad instead of ~iPad and ~iphone instead of
~iPhone for it to work correctly.
Both will work alike on simulator but the prior will ditch on device.
PLease Find the extract from Apple reference for iOS Supports Device-Specific Resources
iOS Supports Device-Specific Resources
In iOS 4.0 and later, it is possible to mark individual resource files as usable only on a specific type of device. This capability simplifies the code you have to write for Universal applications. Rather than creating separate code paths to load one version of a resource file for iPhone and a different version of the file for iPad, you can let the bundle-loading routines choose the correct file. All you have to do is name your resource files appropriately.
To associate a resource file with a particular device, you add a custom modifier string to its filename. The inclusion of this modifier string yields filenames with the following format:
.
The string represents the original name of the resource file. It also represents the name you use when accessing the file from your code. Similarly, the string is the standard filename extension used to identify the type of the file. The string is a case-sensitive string that can be one of the following values:
~ipad - The resource should be loaded on iPad devices only.
~iphone - The resource should be loaded on iPhone or iPod touch devices only.

Related

Localization not working on ipad but working on iphone

I have 2 storyboards each with 2 StoryboardName.string (English and French) and a separate Localize.string that contains the string for the view controllers.
When I run the app on an iPhone it's picking the localization files correctly, but on the iPad it keeps the declared values in the storyboard without useing the values fron the files.
I have tried to delete and install the app multiple time, also I have tried to set a parameter from the scheme configuration, I checked the id's from the localization file to be in the storyboard (and they are). Nothing work...
I modified the localization files but the iPad it's not picking the changes.
How can I force the iPad to chose/use a localization file?
see the target is properly set or not on right side window
The problem was that an " was missing from the storyboard.string files and xcode was not throwing an error. Also I have changed in the scheme at option the application language and the application region.
Helpful tutorial:
http://rshankar.com/internationalization-and-localization-of-apps-in-xcode-6-and-swift/

Images not shown when localising Storyboard in Xamarin IOS

I am working on a project where we need to provide localisation support - (Localisation is provided based on user choice not based on System Settings. ). I have provided localisation support in storyboard and base localisation is also provided.
I was able to get the strings in TextFiled localised using the below code
var languageBundle =NSBundle.FromPath (resourcePath);
var storyborad = UIStoryboard.FromName ("MainStoryBoard", languageBundle);
storyborad.InstantiateViewController ("ViewController");
But the images are not shown at all irrespective of language.
I have placed all my images directly in the Resource folder.
Is there any way to show the images ? Is am missing any information that need to added in the bundle when initiating the story board.
I am new to iOS Development.
I was not able to get exact solution to this problem but i was able to do a workaround. Placing images under the respective locale folder could resolve this issue.
I am using Xamarin studio for development so when i added the required images as links, some times it shown a positive result.

iOS App Localization: Storybords Translation

My storyboards appear to be translated when previewed in XCode but when I install the app on the device nothing is translated to other languages. Here is the checklist.
Storyboards are all translated:
I have some duplicates here - perhaps the reason it is not working:
And finally local file structure on my computer:
Question: how to verify correct file linking or any steps to find the issue of Storyboards not working on the iPhone or Simulator.
You need Base.storyboard and other should be ##language##.strings. Inside these files you will translate things corresponding to ID of the element.
You can check explicitly if the string is translated by calling something like:
NSLog(#"%#", NSLocalizedString("AWO-r7-rD4.text",nil));
You should put instead of "AWO-r7-rD4.text" one of the IDs from Localizable.strings for storyboard.
For comparison:
I have Auth.storyboard, and it can be nested to: Auth.storyboard(Base), Auth.string(English), Auth.String(French).
One stupid thing: Have you changed regional settings in simulator settings?
Hope it helps.

Bundle creator OS Type code ??? in Xcode 4

I just realized that Bundle Creator OS Type code in my iOS app's Info.plist value is ????? in Xcode 4. What is the value supposed to be?
It's used to identify your application. You don't have to change it for an iPhone application.
Take a look at these links:
Information Property List Key Reference
Mac Creator and File Type Codes
Data Type Registration
It's not really used anymore.
It's a holdover from the Classic Mac OS days
when it was a datapoint used mainly to determine what apps could create or edit or read file types.
Back then you had to register them with Apple.
I don't think they even provide that service any more.
OS X and some apps might still use it in rare cases under the hood but its very legacy.
As you can imagine, the severely limited possible permutations made it untenable long term.
UTIs are the preferred approach now. The system then uses a combination of these and file extensions and magic numbers. Though on ios that may not be true as much as OSX.
It is just the four letter code to identify the bunder creator... for example for apple it is APPL...
It can be ???? or if your app name is "myApp" you can give "MYAP"... If you have many apps you can give first 2 characters with your app name and next 2 characters with company name...
For example apple uses CF for core foundation, AV etc
http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
Just to give the historical perspective on extensions and file type and creator codes.
File extensions were part of the file system in CP/M and were intended to function something like what file types and creator codes actually did in MacOS. At the time, it was expected that each application would use a unique extension and only the one application would ever edit its own files. In the file system, the file name and extension were stored in two different areas, so the extension was not part of the name. Remember, at that time most systems had only a few applications, and file contents were specific to an application. They were never intended to be visible to end users, but due to an error in the directory command in CP/M, they were shown displayed as if they were part of the file name. MS-DOS picked up the convention, and the rest, unfortunately is history.
Apple's initial file system design saw the shortcomings of the extension concept, the primary one being that some file types were likely to be used by more than one application and with standardization of file formats, having more than one application that could operate on a file would be common. Therefore Apple split the file creator - the app that created the file - from the file type. By default if a file was double clicked, the originally creating application would open it. However, if a user did a file open from within an application, then all compatible files were supposed to be listed, even if that app was not the creator. Also, it would be possible to list all the applications that could open a file. Semantically, as intended in CP/M, the type and creator codes were separate from the file name itself.
Developers that properly registered their applications with Apple got their own creator codes. The problems with this concept came about from two sources: 1. Developers that hijacked other's or Apples own creator codes. 2. Unix systems, which never had a formal filename extension (all file names were a single string) began adopting the convention to end the file name with a dot and some additional letters to indicate file type. In the Unix convention, the extension is part of the file name itself, unlike CP/M and MS-DOS.

iphone multilanguage support

I'm developing an Iphone app that has to support different languages.
I saw that the language has to be set within my app and not within iphone settings. So, do I have to force the language instead to take the current one? I didn't find examples over the internet. All examples need the current language of the application. I would like that the user choose his language when the application starts, then I will set a cookie and (in a way that iI don't know) the app refers automatically to my .lproj folders with different languages.
This is not possible using the default localization mechanisms in iOS. By default, the system chooses the .lproj folder according to the user's system language and does the localization automatically if you have localized NIBs and use NSLocalizedString() etc..
If you really want to change that behavior and "override" the system language, you have to implement your own version of NSLocalizedString that manually accesses the strings file in the .lproj folder you want. Be aware though that NIBs don't use your custom NSLocalizedString function. So either don't use NIBs at all or do the localizing of the NIBs in code instead of using different NIBs.
Your question isn't really very clear. There is nothing saying that "the language has to be set within my app and not within iphone settings" — it is in fact quite the opposite!
Cocoa has a pretty neat localization system that is quite easy to use (grumbles something about rotten localization workflows). Here's the full skinny on it — basically, have files in lproj folders, then use the NSBundle resource APIs to locate them (NIB loading and other subsystems use it automatically, so you don't even have to do work there!).
IIRC, you want NSLocalizedStringFromTable.
You create a .strings file for each language: eg "EN.strings", "JP.strings", etc...
These files will be loadable from the default bundle with the table parameter to NSLocalizedStringFromTable.
When the user picks a language, you switch which table (.strings file) to load the strings from.
One problem tho is that iOS strings will still be localized to the user's settings, or to whatever you have your app localized to in the Info.plist. So you might end up with a mix of languages.
[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:#"it",#"en", nil] forKey:#"AppleLanguages"];
then if the iPhone language is set to english, my iPhone app will works always with "it". the first of the array.

Resources