UIStoryboard storyboardWithName:#"Keyboard" keeps reloading - ios

I am creating a custom keyboard that recreates the number and decimal keyboard, which is required for app submission. Currently I am using the method:
if ([self isOpenAccessGranted] == false) {
} else {
}
to check whether or not the user has allowed full access. When I try to load my storyboard file (Keyboard.storyboard) with the following method:
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Keyboard" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"KeyboardViewController"];
[self presentViewController:vc animated:YES completion:nil];
The storyboard file just keeps refreshing in my custom keyboard view and functionality for the keyboard does not work. I labeled it with a storyboard id (KeyboardViewController) and checked the storyboardID button.
It is note worthing that when isOpenAccessGrantred is set to true, it loads a programmatically created UICollectionview Keyboard built using a collection frame. I have a suspicion this is what's causing it but not entirely sure.
Any guidance or advice would be greatly appreciated!

I figured it out.
If you are using a Storyboard file with Custom Keyboard make sure to edit your p-list to add the following:
NSExtensionMainStoryboard -> String -> Keyboard
and delete the following:
NSExtensionPrincipalClass -> KeyboardViewController

Related

UICollectionView segue from Sign-up showing a black screen

I have a social app that requires login/sign-up. This is done with the ParseUI library that present a custom window for user validation.
When a user signs up, I want to display a CollectionView where users choose some preferences (each as a cell) and proceed to the app.
In the Sign-Up View Controller I have this:
- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
ChooseLeagueCollectionViewController *clvc = [storyboard instantiateViewControllerWithIdentifier:#"ChooseLeagueViewController"];
[self dismissViewControllerAnimated:YES completion:NULL];
[self presentViewController:clvc animated:NO completion:NULL];
}
Do I need to alloc and init a flowLayout object even though it is already present in my storyboard?
In my storyboard I have a CollectionViewController containing one cell linked to a subclass of UICollectionViewCell with an ImageView and a Label. This storyboard file has as custom class 'ChooseLeagueViewController' which is a subclass of CollectionViewController, and is also data source and delegate.
In the .h file I have:
#interface ChooseLeagueCollectionViewController : UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
In the .m file I implement all the required methods that the datasource and delegate protocols require. In cellForItemAtIndexPath I populate the cell (subclass of CollectionviewCell), change the label text and text color, the image, and than return it.
Also I am not sure why I am asked to register my cell like below, even though my cell has a reusable identifier in the storyboard.
[self.collectionView registerClass:[LeagueCollectionViewCell class]forCellWithReuseIdentifier:#"leagueCell"];
Anyway when I run the app, after signing up, i am brought to a completly black screen but the battery. the app does not crash and all the 'data source' methods are called correctly.
I think that there is something wrong in the way I am trying to show this View.
Any guess on how I could improve my segue or what the mistake is?
thanks in advance
Simply alloc,init will give you blank controller with no view associated with it. You have to initialise it through storyboard like this, then you will not have to provide any custom init/alloc,
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
ChooseLeagueCollectionViewController *vc = [storyboard instantiateViewControllerWithIdentifier:#"yourViewControllerIdentifier"];
[self presentViewController:vc animated:NO completion:NULL];
You specify viewController identifier in storyboard by selecting your viewController and in identity Inspector in storyboard id. :)

iOS/xcode - How can I open a new storyboard from UITabBarController and keep the UITabBar from disappearing?

I have been working to link multiple storyboards off of a singleUITabBarController. I have it working where I can get the new storyboard to open and present the initial UIViewController, just the UITabBar disappears when it opens the new storyboard.
Here is the code I am using to switch to the new storyboard:
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
if ( [viewController isMemberOfClass:[ProfileRedirectViewController class]] )
{
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Profile" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"ProfileTableViewController"];
[self.view.window.rootViewController presentViewController:vc animated:YES completion:nil];
//[self.navigationController pushViewController:vc animated:false];
return NO;
}
return YES;
}
I had been playing around with thenavigationController version, but it would just do nothing and resulted in a dead click and no errors in log. I have been searching for an answer to this for a bit and maybe i've been going down some wrong paths. I am new to xcode so I could very well be missing something obvious or using wonky search terms to find help.
The UITabBar works fine when we are navigating to any of the other views within the main storyboard, it's only when I move to the next storyboard that we lose it.
All help is much appreciated!
you are telling the view window to load a new root but what you want to be doing is have the UIBarTab open the other storyboard. Take a look at his post there is a very good detailed answer: Proper Way to Open a New Storyboard through UITabBarController

Is It possible to segue to a specific view controller from another storyboard

Within my app i have 2 storyboards, one has all the configuration screens and the other has the main screens of the app.
In one of the main screens of the app the user can press a button which allows them to go back and edit or add anything to the configuration.
The issue is if the user came from the main screens, once they press the done button on the configuration screen to confirm their changes, is there a way i can segue back to the main screen storyboard and then segue to the screen they were previously on before going to configuration ?
You need to have code to transition between the storyboards.
- (IBAction)showNextStoryboard:(id)sender
{
UIStoryboard *nextStoryboard = [UIStoryboard storyboardWithName:#"SecondStoryboard" bundle:nil];
UIViewController *nextRoot = [nextStoryboard instantiateInitialViewController];
[self presentViewController:nextRoot
animated:YES
completion:^{}];
}
And to return:
- (IBAction)returnToPreviousStoryboard
{
[self.presentingViewController dismissViewControllerAnimated:YES completion:^{}];
}

Unable to pushViewController iOS

I am using storyboard in my app, :
I have Button in my View, On click of button i want to navigate to new View
But when i click on button nothing happens,
Here is my Code:
- (IBAction)JoinClicked:(id)sender{
JoinWithViewController *detail_view_controller = [[JoinWithViewController alloc] initWithNibName:#"JoinWithViewController" bundle:nil];
[self.navigationController pushViewController:detail_view_controller animated:YES];
}
Where i am doing mistake , please help.
Thanks in advance.
Set storyboard id of view controller in story board in identity inspector
Make a reference to your storyboard like
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
then to your controller
YourController *vc = [storyboard instantiateViewControllerWithIdentifier:#"YourController"];// storyboardId
[self.navigationController pushViewController:vc animated:YES];
and you can also make segue and do
[self performSegueWithIdentifier:#"YourSegueIdentifier" sender:sender/nil];
use this one :
- (IBAction)JoinClicked:(id)sender{
[self performSegueWithIdentifier: #"JoinWithIdentifier" sender: self];
}
and add segue in storyborad like
Make an identifier for your push-segue in storyboard.
then use
[self performSegueWithIdentifier:#"YourSegueIdentifier" sender:nil];
When using story boards you should use segues for as much navigation as possible.
Your code seems fine, please verify your outlets correctly configured or not in xib or storyboard.
Edit:
You are using storyboard and wants the xib file to get pushed onto your view controller if I am not wrong, you can drag another view controller in storyboard and name it JoinWithViewController and push using segue on button click. That is much easier than what your trying to do here.

Launch different ViewControllers on a button click in iOS

My project is in iOS6.I have three UIViewControllers on my iPhone storyboard. On the first UIVC i have a checkbox and a continue button. If checkbox is checked and button is clicked then I have to launch second UIViewController.If checkbox is unchecked and button is clicked launch the third UiViewController. How do i do it? I have done this so far:
- (IBAction)btnContinue:(UIButton *)sender
{
if (self.shipToDifferentAddress)//Checkbox CLICKED->YES
{
//Launch ShippingVC
ITMShippingAddressVC *shippingVC = [[ITMShippingAddressVC alloc]init];
[[self navigationController]pushViewController:shippingVC animated:YES];
}
else //Checkbox unchecked ->NO
{
//Launch OrderedItemsVC
ITMOrderedItemsVC *orderedVC = [[ITMOrderedItemsVC alloc]init];
[[self navigationController]pushViewController:orderedVC animated:YES];
}
}
The self.shipToDifferentAddress is a bool variable telling launch this or that. I logged both the viewDidLoads and i got the output from both of them.There is some content on both the second and third UIViewControllers like buttons, labels etc. But they appear black.No content. I have back buttons on both of them and I can traverse back to first UIVC from either one of the one. SO what am i missing? I used segues incases where I had to go to a specific UIVC. Now i have a choice either second or third. How should i do it?Please let me know if you need more information. Thanks.
To present your ViewControllers that are in your storyboard, follow this:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard"
bundle: nil];
ITMShippingAddressVC *viewController = (ITMShippingAddressVC*)[mainStoryboard
instantiateViewControllerWithIdentifier: #"ITMShippingAddressVC"];
Set the Identifier in your storyboard.. click on your view, and in the right properties menu set the Storyboard ID
Than you can push like normal:
[[self navigationController]pushViewController:viewController animated:YES];
While this will work for you-- when using Storyboards, ideally you want to use Segues. It requires much less code. Here is a good tutorial on using segues to push/present view controllers and pass data between them.
You have created your VC's, but they are not linked to the storyboard ITMOrderedItemsVC and ITMShippingAddressVC. So the interface that you added in storyboard doesn't get loaded.
What you could do is create a separate xib file for each of your VCs (New > file... > User Interface > View). Name the xib file the same as your viewController:
ITMOrderedItemsVC.xib
ITMShippingAddressVC.xib
Design your interfaces in these xib files (they are just like single-entity storyboards).
The xibs will be automatically loaded when you init an instance of the respective viewController.
This will work with your current code.

Resources