Need advise in implementing ECSlidingViewController - ios

I am trying to deploy from scratch something like BasicMenu example.
Steps are already done:
ECSlidingViewController created in storyboard with proper User Defined Runtime Attributes and set as init view.
MenuViewontroller created with identifier: MenuView and unwind method
HomeScreenViewController created with identifier: HomeScreen and rooted by UINavigationController
Created sliding segue from first cell in MenuViewController.tableView to UINavigationController of HomeScreen
In HomeScreenViewController created UIBarButtonItem with action binded to Unwind method.
After starting app all looks like Ok, but when I am tapping Menu button in the NavBar nothing happens. Also unwind method of MenuViewController not called.
P.S. I figured out that MenuViewController is not instantiated at runtime. No idea why =(
P.P.S. I found the issue!!! It was very stupid mistake - i am not appointed class to ViewController in the Storyboard.

The issue was in appointment class to view controller in storyboard. It was by default UITableViewController instead MenuViewController.

Related

NavigationController StoryboardSegue not showing navigationBar and navigation delegate not called

I recently changed my app structure to include a UINavigationController as base for my hierarchy and I had its root viewController implement the UINavigationControllerDelegate protocol in order to implement custom segues.
My viewController implements navigationController:animationControllerForOperation:fromViewController:toViewController:.
My problem is two-fold:
The navigationController.delegate methods are not being called.
The navigationBar is not called in the views being pushed via storyboardSegues of type show.
The prepareForSegue:sender: function is being called.
This is my UI:
Turns out that UIStoryboardSegues I added before I added the UINavigationController to my hierarchy are still interpreted as modal segues. Probably this is set during creation.
The problem was solved by deleting and re-adding the segues in question, with the relevant information (identifier, class...) transferred to the new instance.
If you have the same problem, when you set Top Par to inferred in your segued viewController you will see no navigationBar showing.
After replacing the segues the Top Bar showed again as normal.
Edit:
I posted the question together with this answer, since there was no post on SO covering this issue. self-answer

Add parameters to TabBar Storyboard segue

I have a TabBar with 3 buttons, the 2nd and 3nd buttons have a segue to the same controller, which should show different info depending on one param.
I've overridden TabBar class to implement.-
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender;
to be able to add my param just before performing the segue, but I must be missing something obvious because prepareForSegue is not getting called.
Is there anyway to achieve this without programmatically creating custom segues?
According to me you cannot interact with segue linked as "root" controllers.
Those segue are not "getting called" as they don't represent a transition between two view controllers.
If you look at Interface Builder there is no settings available for that kind of segue.
I had a similar issue in one of my project and solve the issue by setting the controllers programmatically. After that you add your view controller in storyboard and set a "Storyboard ID" in the right hand panel.
Then, you can instantiate your view controller by doing
[self.storyboard instantiateViewControllerWithIdentifier:#"YOUR_VIEW_CONTROLLER_ID"];
And affect them to your UITabBarController by doing
[self setViewControllers:viewControllers];
Hope this help!
Not sure if it's the best practice, but I finally ended up getting the selected tab from my controllers.-
self.tabBarController.selectedIndex
This simple way, I know what info should I show, without changing my storyboard segues.

Adding a navigation controller to a tab bar application

I have two questions about this one. First, I have the navigation controller successfully put in the storyboard and is linked with the tabs and is working how I would want it to. Except for one thing. When I try to add a code such as this
[self.navigationController popToViewController:vc animated:YES]
I get an error Property 'navigationController' not found on object of type 'AppDelegate *'
Is this because I put it in the wrong place? Or becasue its a tabbar application and something aint right.
It sounds like you're trying to make a call to your navigation controller from your AppDelegate. Unless you've specifically setup your AppDelegate to work with your navigation controller (it'd need to be a subclass of UIViewController), you'll get an error because there is no Navigation Controller on your AppDelegate class (by default). Therefore, when you make that call - the navigation controller can't be found. Notice how your AppDelegate is a subclass of UIResponder, not UIViewController:
#interface AppDelegate : UIResponder <UIApplicationDelegate>
Instead, create and / or connect your navigation controller to a UIViewController subclass - then you can make calls like this from your subclass:
[self.navigationController popToViewController:vc animated:YES];
To create and setup a Navigation Controller, follow these steps (may vary if you aren't using storyboards).
Create a new UINavigationController Obj-C subclass. In the Xcode menu bar, select File > New, or press CMD+N. Name your class and set its superclass as UINavigationController:
Note that you don't absolutely need an entirely new class! You can use an existing class that is a subclass of UIViewController - as long as the navigationController property is available.
Add your navigation controller from the objects library in Xcode and set it up the way you need it.
Select the NavigationController in your Storyboard, then open the Utilities Panel, and select the Identity Inspector Tab. Set the Custom Class name to the name of your UIViewController or UINavigationController subclass:
From your class you'll be able to use the navigationController property, among hundreds of others relating to the View Controller. Remember that the AppDelegate is really a place for setting up your app and handling app events (ex. app closing, app backgrounding, app opening).

Where to set up a TableViewController's UIBarButtonItem & cell "segue" programmatically

I have a TableViewController that can be transitioned to from two other view controllers; one transitions by segue, and the other programmatically. Everything works well when transitioning via segue, but when the TableViewController appears after a programmatic transition, the UIBarButtonItem is missing and the cell segue doesn't work (it should take the user to a new screen).
I'm guessing that because the UIBarButtonItem and cell segue were setup in the Storyboard, they aren't loaded when the TableViewController is loaded programmatically. So, I'm assuming that I need to load them manually somewhere. My question is where the appropriate place to do this is?
Thanks for reading.
EDIT:
Here's the code for the transition:
OtherTVC *otherTVC=[[OtherTVC alloc] init];
[self.navigationController pushViewController:otherTVC animated:YES];
This is linked to the callout accessory of a map pin.
To get an instance of the controller as it was created in the storyboard, try giving it an identifier and using instantiateViewControllerWithIdentifier: rather than the alloc/init route. If your current controller where the code is running came from the same storyboard, you can get a reference to it through the controller's storyboard property in order to make that call.

iOS storyboards instantiate viewController and IBAction

I may go mad very soon.
This is the reason:
- I started up with Single View Application project with storyboards. Then I set the view controller class name in the storyboard for my viewController.
- Next step I created one pointer for this viewController in AppDelegate method ...didFinishLaunchingWithOpt... and filled it up by calling [myStoryboards instantiate...]. It works pretty good because I can call method like [vc1 setMyName] which does smthng like self.myName = #"Johnny";
- But here it comes. When I create IBAction method joined with button, this method doesn't know anything about "Johhny". And this is because I'm in another instance. When I check the address of "self" it is another one...
WhyWhyWhy??? Please help, how can I use still the same object - the one instantiated in AppDelegate by storyboards and the one from storyboards in "interface builder".
Thank you.
Oh my. I think I really underestamated it...
When we were talking about getting pointer of other viewControllers from storyboard...
I have initialViewController got by calling rootViewContr... And another one connected with segue (modal) where is UITableView. A get data on rootViewController and I want to show them on the other one in the list (UITableView). So I call segue (performSegueWithIdentifier), the other controller is shown but the list is clear. Because the method I call is working with tableView variable which is null :/ Because, again, I'm in another object. That is because I call that method storyboard instantiate... How can I get exactly the same viewController which I'm working in storyboard with. It is quite confusing for me :/
I read something about prepareForSegue and getting the pointer by destinationViewController but that is not what exactly I want. I need the pointer before I call segue method and the viewController is shown...
Thank you.
If you've set up your initial view controller properly in the storyboard, you don't need to assign it to the windows rootViewController property in -applicationDidFinishLaunchingWithOptions: as this is done for you automatically. It sounds like you're creating a second instance. To access the original instance setup by the storyboard simply do this in -applicationDidFinishLaunchingWithOptions:
InitialViewController *viewController = (InitialViewController *)self.window.rootViewController;
viewController.myName = #"Johnny";

Resources