Unable to find storyboard after rename - ios

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.

Related

Cordova plugin, with native storyboard UI

I am in the midst of creating a Cordova camera plugin. I know there are many alternatives out there, but none of them have all of the functionality that I am looking for, or they are outdated.
So I have been working with the AVCam-iOSUsingAVFoundationtoCaptureImagesandMovies project that Apple provides to get you started with their AVFoundation library.
After working with the library a bit, I realized that I wanted to make it into a Cordova plugin, but the only thing that I am concerned about is the UI functionality of the plugin. So I am wondering if it is possible to include the storyboard files (that render the view / buttons) in the Plugin, so that they work seamlessly, or if it needs to be programmatically created, like other Camera plugins (like CameraPreview) do.
Yeah, you can add a storyboard to a plugin.
First add the storyboard in the plugin.xml
<resource-file src="src/ios/YourStoryboard.storyboard"/>
Then in the code you can get the initial view controller like this:
UIStoryboard* sb = [UIStoryboard storyboardWithName:#"storyboardName" bundle:nil];
UIViewController * vc = [sb instantiateInitialViewController];

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.

STORYBOARD EXCEPTION - Storyboard doesn't contain a view controller with identifier

I am currently developing an iOS application for both iPhone and iPad. I'm trying to show a NavigationController to make a module that shows files. In an iPhone it works just fine, but I canĀ“t get it to work in iPad.
I'm getting the following error:
'Storyboard (<UIStoryboard: 0x919b200>) doesn't contain a view controller with identifier 'FilesNavigation''
and this is the code:
case 10: // Files
{
UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:#"FilesNavigation"];
FilesViewController *filesViewController = [storyboard instantiateViewControllerWithIdentifier:#"Files"];
[navigationController pushViewController:filesViewController animated:YES];
self.slidingViewController.topViewController = navigationController;
break;
}
And in my storyboard I have already set the Storyboard ID for the navigation controller.
>##Custom Class
>Class: UINavigationController
>##Identity
>Storyboard ID: FilesNavigation
I used this code for another case on the switch/case block for other module and it works for iPad too, its the first time that I have this error.
I figured it out, the problem was that the Storyboard wasn't updating in the device.
Uninstall the app from the simulator/iPhone/iPad
Product > Clean
Build & Run
As stated in #T0m_Twt's answer in this question
In the right pane, in the identity inspector section give a storyboard Id to your Navigation Controller.
I took a screenshot for you
Here's another case:
There are two localized storyboards. Only one of them has the view controller you want.
By chance, do you have a storyboard for iPhone and a different one for iPad? If you do, then the iPad one might not have a storyboard with that identifier. Also when running on an iPad, set a break point in your code and verify what your "storyboard" object is.
I use a category on UIStoryboard that will give me the storyboards for each platform.
I can use [UIStoryboard storyboardHome] and that will determine if it needs iPad or iPhone specific and return that to me. I also ensure my storyboards follow proper naming. So I would have Home_iPad and Home_iPhone.
TL;DR - clear everything and remove old version of the app as well, if there's any.
It may sound crazy, but suppose that if you have changed target name which changed bundle name as well, you might have both the old and new version of the app installed in the simulator / device, and this might cause trouble for the UIStoryboard instance failed to instantiate some view controllers, which might eventually cause the trouble described in the question. To solve it, you need to remove all related apps or simply reset the simulator / device.

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"

XIB file disappeared but application still works

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.

Resources