XIB file disappeared but application still works - ios

I'm using Xcode 4.0.2 and I opened up one of my projects today to find that a .xib file was missing (the .xib that the MainWindow loads). I can't see it in the Finder and it doesn't appear at all in the Xcode window, yet my application still works as if it's there.
Anyone have any idea what might have happened here?

Cmd+Shift+K to clean. Then rebuild and re-run. What exactly is the issue? That its running with the XIB file or where the XIB file went?.. Maybe its not using a XIB file at all (After-all, its not neccessary).

I'm guessing you didn't have any custom work in that nib. In your delegate on the line self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil]; it tries to load the ViewController.xib file. Since it can't, it's the same as calling self.viewController = [[ViewController alloc] initWithNibName:nil bundle:nil]; which produces a blank generic view.

Related

The "Empty Application" Is Missing In the Newer Xcode Versions (Objective-C)

In old versions of Xcode, an "Empty Application" would be a project with all the information to build and everything, but no files except the App Delegate would be added.
In the newer versions of Xcode, the "Empty Application" option is no longer the same. Instead of creating a project with no files but the App Delegate, it creates nothing at all! You either have to drag in other files pre-made, or you have to create all the files, including the App Delegate and all of it's once "default" functions.
How would I get the previous version of "Empty Application"? "Single View Application" is a little different, but nothing else seems to be similar.
How would I get the previous version of "Empty Application"
You would have to make it for yourself by paring down the Single View template-based project.
So, for Objective-C:
Delete the storyboard.
Edit the target and delete "Main" where it asks for the storyboard name. Hit Tab to make this change "stick".
Delete the view controller files.
Make a new view controller and (optionally) a .xib paired with it, to give yourself a starting place. Let say it's called MyViewController.
Delete everything in the App Delegate implementation of applicationDidFinishLaunching and replace it with:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [MyViewController new];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;

Unknown class CustomViewController in Interface Builder file using a storyboard from a library

I've read many other questions about this but didn't find a solution right now and my issue is perhaps a little more specific than what I could see elsewhere.
So currently I build a static library including some other frameworks, a bundle with graphic resources + storyboard and subclasses of UIViewController assigned in "Class" field of my storyboard's view controller.
When I use my lib in a test project, it seems I can load the view controller from storyboard but I crashes with "unrecognized selector sent to instance" once I press any control in the view.
Also Xcode reports : "Unknown class CustomViewController in Interface Builder file." before.
Here is the code I'm using to load it:
NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:#"careersbundle" withExtension:#"bundle"]];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setBackgroundColor:[UIColor blueColor]];
self.sb = [UIStoryboard storyboardWithName:#"MainStoryboard_iPad" bundle:bundle];
self.vc = [self.sb instantiateViewControllerWithIdentifier:#"Player"];
[self.window setRootViewController:self.vc];
//...
As I understand, I don't need to reference any .h file in includes as my project only needs to load the ViewController and it should then work on his own with IBAction.
I see that setting project's "Other Linker Flag" to -ObjC should help but dosen't solve my issue. I set this flag in my library project (not the test project) but I'm not sure I'm doing it right like this ?
I also see developers using "[CustomViewController class]" to force linker to keep reference to class but they use it in main.c and I didn't have a main.c in my library project...
I'm lost with this, can someone point me to settings I have to do in the library project and then in my test project to make it works.
Thanks
I finally implemented the complete interface in code using nib2objc tool to convert my storyboards views's properties in code.

Xcode 5 Simulator Blank White Screen

I just installed Xcode 5 (or the latest version) and created a new project. I created a storyboard, and added a label, but when I open my application in the iPhone simulator, I simply get a blank white screen with a status bar. What am I doing wrong?
I have OS X 10.9.1 Mavericks.
I know I'm quite late to this, but the solution to this problem is quite simple and is even shown in one of Apple's own tutorials.
Assuming that you started off with an "Empty Project", created a storyboard from scratch, and set your storyboard as the main interface, you need to remove a few lines in the first method of AppDelegate.m.
This:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
Should become just this:
return YES;
I'm going to assume that you started an empty project, which doesn't start with a storyboard and then after creating the project, you created a storyboard file.
You have to tell your app which storyboard to load.
In the below screen shot, you'll want to click the "Main Interface" drop down and select the storyboard you want to start your app with.
This is the "Deployment Info" section of the "General" tab of your targets.
You also need to add a couple lines of code to your AppDelegate.m. It should look like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"YOUR_STORYBOARD_NAME" bundle:[NSBundle mainBundle]];
UIViewController *vc =[storyboard instantiateInitialViewController];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
return YES;
}
Your project does not have a view controller. When you created your project, you should have started with a "Single view project", which would have created a view controller for you. In that case, you would have been able to see your label.
EDIT TO FIX:
If you would like to fix this, remove the property "Main nib file base name." This can be found in the "info" tab of your target.
The problem:
It seems that when you created your application, you selected the "Empty Application" template. Then you added the Storyboard from the user interface section. When you added the label and ran the application, you can't see the "Hello, World" label, because the application does not have a root view controller at the end of the application launch.
Try to create a "Single View Application".
Just wanted to chime in on this thread and shed some light on the matter. I myself was working on my first project and was getting the white screen. I found this article and it helped and it didn't, but this is what worked for me. Everyone is right on what they posted, but I was running 9.2 simulator when in fact I only have 9.1 installed (if you need help with this go to Xcode> Preferences>Downloads and download the appropriate package. Once I did that I ran the simulator and got the white screen. Now my white screen had the carrier and batt icon at the top. To fix this issue in Simulator: Hardware>Device>9.1 and a reboot occurred and then it works...
Hope this helped.
SithAdmin
I had the same issue (blank screen) for a stupid simple error. Actually, the elements appeared and soon fade away.
My mistake was that I was not creating in in Main.storyboard (but LaunchScreen.storyboard in place, so that it obviously disappeared couple of seconds after start).
Stupid but at least, quick to check: create views in Main, not LaunchScreen...
Click "Main.storyboard" -> on right prat "Interface Builder Document" uncheck "Use Auto Layout, "Use Size Classes" & "Use as Lunch Screen"

Unable to find storyboard after rename

in an iphone Application I have created a storyboard named HomeStoryboard.storyboard, and I get reference to it using:
UIStroyboard *storyboard = [UIStoryboard storyboardWithName:#"HomeStoryboard" bundle:nil];
This is working correctly.
However I wanted to change it's name, so I renamed the file to HomeStoryboard-iPhone.storyboard
Now when I try to call
UIStroyboard *storyboard = [UIStoryboard storyboardWithName:#"HomeStoryboard-iPhone" bundle:nil];
I get an error:
'Could not find a storyboard named 'HomeStoryboard-iPhone' in bundle NSBundle ....
It seems like renaming the file is not enough.
What can I do to rename a storyboard?
Thanks
Try to reset your Simulator and then clean your App Build Folder.

How to integrate the InAppSettingsKit?

I have just downloaded the InAppSettingsKit and I'm trying to integrate it with my app however I'm having some issues with it since I can't find any documentation to help me out. So far I've done the following steps...
I added the InAppSettingsKit directory to my Xcode project.
I created a new UIViewController class for my settings (which I named settingViewController).
At this point I have become a bit stuck as I'm not sure what needs to be done. If someone could offer some steps on how to integrate this it would be really really helpful as I can't find any up to date documentation online.
Usually, you don't need 2. You just configure a button action to display IASKAppSettingsViewController. This could look like this (in this case for a modal presentation):
appSettingsViewController = [[[IASKAppSettingsViewController alloc] initWithNibName:#"IASKAppSettingsView" bundle:nil] autorelease];
appSettingsViewController.delegate = self;
appSettingsViewController.showDoneButton = YES;
UINavigationController *aNavController = [[[UINavigationController alloc] initWithRootViewController:appSettingsViewController] autorelease];
[self presentModalViewController:aNavController animated:YES];
Check MainViewController.m in the sample app for different ways to present it (navigation push, tabBarItem, etc.).

Resources