Trying to make an existing app having two different set of .h .m and .xib files for each view. Now for a single view am using only one .h & .m file and two .xib file.
eg.
ViewController.h, ViewController.m, ViewController~iphone.xib, ViewController~ipad.xib
Problem: At compile time i get errors for the files in my code i have not set their target for iphone and ipad both.
Go to Project -> Targets -> Build Settings -> Targeted Device Family . Set it to iPhone/iPad.
Enjoy Programming!!
Better solution is add target device for existing class
Related
I am converting my application into Universal, So I have created iPad xib with ~ipad.xib extension. Now I want to use all the old UIControls used in iPhone.xib in iPad.xib without recreating and connecting, Is there any way to reuse it? I have checked in one SO question he mentioned copied and used it in iPad. How to do it?
First take back up of your application.GO to your app target section and right click there u will get three option like Duplicate, Delete, Project Editor Help....Now Select Duplicate it will show alert like below image. Now select "Duplicate and Transition to iPad".Xcode will generate all xib's for iPad with connections.Copy all xibs of iPad to original application.
just select all controls make copy & paste in new .Xib .
I have two targets in my Xcode 4.3 project. Each target has its own X-info.plist file. I would like to have two windows (MainWindow.xib), one for the full app and one for the Lite version. I set the Main Interface for each target and also Main nib file base name in the X-info.plist but it's not working. What did I miss?
Thx
You can add a Preprocessor Macro to the target of the lite version LITE=1. Then in your code, when you want to execute something differently you can use #ifdef, for example:
NSString *mainWindow;
#ifdef LITE
mainWindow = #"MainWindow_Lite";
#else
mainWindow = #"MainWindow_Full";
#endif
// Load nib with the name mainWindow.
// Or load ads in the lite version
// Or disable functionality in the lite version
//
If you want to avoid doing that and want to use the same name for the two nibs, you have to add one of them as a member of the full target and the other one as a member of the lite target.
You can easily have the even same names for .xib files for different targets. Just make sure that two files with the same name aren't members of the same target. They have to be placed in different directories on HD and in different groups in project.
There is also a known bug with IB (image resources and so on) and multiple targets: see more at Two targets with separate .xib (image resources with same names)
But this information is for XCode 4.2.x, not sure if it/s valid for XCode 4.3
I've created a View Based Application in XCode4; when creating the application I selected iPhone as the Device Family:
The application was created with the following files:
I designed the UI on the TestushViewController.xib file and without adding any code in the Delegate files, the application is uploading immediately to the TestushViewController.xib view and I'm very happy about it.
Now I want to add an iPad xib. How do I do that?
(I knew how to do it in XCode 3, but I used some code in the Delegate file, and now if I try to use the same code it doesn't work because the template default implementation works differently - Apple uses #class TestushViewController and self.window.rootViewController = self.viewController and it goes directly to the iPhone.xib. I don't know how to go around it without changing the entire thing to the way it was done in XCode3)
You'll need to structure your code in a similar way that the Window Template does. The file structure that template uses when the "Universal" option is ticked at creation is:
App Name/
AppNameAppDelegate
iPhone/
AppNameAppDelegate_iPhone
MainWindow_iPhone.xib
iPad/
AppNameAppDelegate_iPad
MainWindow_iPad.xib
The iPhone and iPad AppDelegates are simply subclasses of the AppNameAppDelegate
#interface YourAppNameAppDelegate_iPhone : YourAppNameAppDelegate {}
In your target summary you can set what .xib file is initially loaded for each device. It is called the "Main Interface" and has a pulldown menu.
Quite frankly, if you're wanting to do a universal app (iPhone + iPad) it's probably easier just to start with the Window Template and add in your view controllers instead of starting with the View template and trying to change it up.
I am developing an application for the iPad. The application has following details:
Base SDK: 4.2
Deployment Target: 3.2
The application is a game application and it has got 10 rounds.
In each round I am loading 6 controllers and after the completion of each round again the same cycle starts.
The application works fine till 4 rounds but at the end of 4th round it crashes given following error:
"NSInternalInconsistencyException Could not load nib ind bundle:"
I have checked for everything solution like checking the nib file name, checking the nib file path. Nib file name and nib file path both are correct and targets are also correct but still it crashes.
Any help for this will be appreciated.
Thanks,
Shyam
Right click your nib file in xcode and make sure its type is 'file.xib'.
I had this problem too, in my case the cause was that my project had no localization to italian but the app was running under "it" settings.
The simulator has English as regional setting by default, everything was ok on it while the actual device had italian settings, so the app crashes immediately when attempting to load the RootViewController, because it was looking for an italian version of it.
In XCode I added an italian localized version to the RootViewController (now I see two entries under it, one for english created by default and italian). Note that you don't need to do the real translations in the view, it's enough that you create it and leave as default. Xcode copies all labels and text from the original view, you just leave as is for the moment.
You'll have to do this for each view controller in your project. Refer to Apple docs, for explanations on internationalization and localization here.
As a workaround, some people might prefer to change the device regional settings to English while performing tests...
I am trying to localize a class (.h & .m files) in my application. I made the same operation as when I localized my interface (xib -> Get info -> make file localizable). I created a second .h and a second .m file, and I made the modifications I needed for the new location. Great !
But it just doesn't work...
I get the error:
duplicate symbol _OBJC_METACLASS_
Does anyone have a clue ? Thanks a lot !
you are just on the wrong path..
For localization you need not create separate .m & .h files.Only Xibs are to be created.
Other than that you have to create separate Localizable.strings file for each localization.
For more understanding just chk out this link http://www.switchonthecode.com/tutorials/a-simple-localization-example-for-the-iphone
It contains the link for downloading the sample code also.