I am using x-code 4 and any time I start a "view based application" (say "Test") IB opens up and creates 6 files. 1)TestAppDelicate.h 2)TestAppDelicate.m 3)MainWindow.xib 4)TestViewController.h 5)TestViewController.m 6)TestViewController.xib
Now the Main Interface is set to MainWindow yet when I run the app it always starts up the TestViewController.xib not mainwindow.
The problem is If I change from iPhone to Universal app it creates a MainWindow-ipad.xib that is unusable. How do I get it to use mainwindow?
Is this a bug? Or am I doing something wrong or am I uninformed?
The MainWindow.xib creates the root window and sets it's view controller to the TestViewController. TestViewController's contents are created in the TestViewController.xib.
In other words, you ARE using the main window.
Related
I've created a splash screen in Swift using Xcode 7. I've generated localizations as in the photo for different languages, but it doesn't work:
Can anybody help?
Ok I fix it after i create InfoPlist.strings and create splash screen for each language and add below in each file
"UILaunchStoryboardName" = "LaunchScreen";
"UILaunchStoryboardName" = "LaunchScreenSP";
Add two Launch Screen storyboards
You can find your info.plist added a key named "UILaunchStoryboardName"
Add an infoPlist.string file
Change the UILaunchStoryboardName = "ENLaunchScreen"; in your infoPlist.string to the name of storyboard you wanted
Another solution, you can set some basic image at the launch screen, then create a view in app delegate and add in to window's subviews, also bring to front pretend that this is Launch screen.
now you can configure this view by code.
last use DispatchQueue asyncAfter to remove this view.
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 .
How can i display a XIB interface on an UIView!Please be simple!
a UIView interface built in a XIB can be displayed by linking that XIB with a UIViewController.
Check out the Apple documentation About Windows and Views.
And you can see how a XIB is set up just by creating a new project in XCode and choosing "Single View Application" as a template. If you're using XCode 4.2, the "MainStoryboard.storyboard" file appears to be the new name for a XIB file.
Which reminds me I should go check out the WWDC session online that talks about this -- and you should too. If you're a registered developer, it's free to check out! My educated guess is that the "Designing User Interfaces for iOS and Mac OS X Apps" session (at https://developer.apple.com/videos/wwdc/2011/?id=110) is the one you want to see.
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'm getting this error message when I Build&Go:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason:
'-[UIViewController
_loadViewFromNibNamed:bundle:] was unable to load a nib named
"TestappViewController"'
I created a blank new project and then started to create a RootViewController which holds two other UIViewController's. XCode automatically created the TestappViewController, and I deleted it to start totally from scratch. MainWindow.xib shows me no TestappViewController in IB, but inside the XML structure of MainWindow.xib I find this:
<object class="IBUIViewController" id="943309135">
<string key="IBUINibName">TestappViewController</string>
<object class="IBUISimulatedStatusBarMetrics"
key="IBUISimulatedStatusBarMetrics"/> </object>
I checked all my XIB's for a reference to an TestappViewController, but there's nothing.
Testapp-Info.plist points to MainWindow.xib only.
Tried to delete this part out of the XML from MainWindow.xib, but this gives some weird Xcode errors, so I re-inserted it. I assume the bug in the XIB files, but don't find anything.
Any idea at which point I could fix that?
Finally I figured out that I had to delete and recreate the View Controller object in the MainWindow.xib. Previously I just edited the existing View Controller object and directed it to another class, which doesn't seem to work properly. Now all is fine :)
Go to iPhone Simulator, then click on "Reset content and settings". That did the job for me.
In iB in the connections inspector for the mainwindow make sure the connection to the TestappviewViewController is deleted
I had this problem, none of the above solutions worked. For me, I had to right click the xib file in the Resources folder > get info and in the Targets tab make sure the target box for my app was checked.
Most likely, the file's owner of the View Controller object in the MainWindow.xib was set to TestappViewController, instead of UIView controller. What you could have done is change it back to UIViewController in the Identity Inspector (4th TAb)
Go to: Application Support -> iPhone Simulator -> *your_simulator_version*
Delete the folder related to your app, clean solution, run the app.
It worked for me... the problematic xib was still in that folder after i removed it from the project and for some reason, the app tried to load it even if there was absolutely no ref in xcode.