Set up class delegate from UITabBarController - cocoa-touch

All,
After my previous experiences I am a little reluctant to ask this - but I can't seem to find an answer anywhere...
I have 2 viewcontrollers in a uitabbarcontroller. One of them is a settings table - the other is the main view controller for my app. There are controls I would like to update in the main view controller when a setting is changed.
I've set up a delegate method in the settings view controller to that should allow this - but obviously as the settings view controller is not called from the main view controller - it doesn't work using the normal set up.
Is there anyway I can used the tabbarcontroller to set up the delegate relationship when the app starts?
I greatly appreciate any help that can be given.
Many thanks in advance...
Steve

Problem solved... I had forgotten that I have Navigation VC's between the TabBarVC and the main and settings VC's!

Related

UINavigation Controller Root View Change

I recently encountered a small problem with Storyboards. I have a UINavigationController than has a relationship with the MainView RootViewController(This one has all the buttons leading to the rest of my app). However, I tried to change the RootViewController so that I could enable persistent login rather than a UIWebview Login. When I made the new Logon Form ViewController as the Root, the buttons on my MainView simply stop working.
I also have set the UINavigationController as the initial View Controller.
Any ideas on what has to be done here?
I do know that I can simply have the logon screen in the storyboard and call it programmatically, set it to advance on a boolean condition(loginDidSucceed). However, I am confused on why this behavior happens in StoryBoard.
Solution Referred from: Present Splash/Login ViewController With StoryBoard
Thanks for the Help and Effort!
I think the principal problem here is that the target of your butttons is the old view controller instance; when it goes out of scope their target no longer exists.

Can a splitview be loaded inside the detail view of another splitview?

I am trying to develop an application that has screen flow similar to oracle app. I have attached the images here. Can anyone please tell how this can be achieved ?
Thanks in advance.
What you are looking for is a custom Split View Controller. The screenshots you provided are of custom split view controllers. The UIKit has UISplitViewController but this must be a fullscreen view controller.
To make a custom split view controller there's the old way, by having a main view controller and making your two master and detail controllers, adding their view to the main view controllers view.
You need to forward on calls from viewWillAppear:, viewWillDisappear: etc from the main view controller to the two controllers that you manage.
As of iOS 5, you can do something similar with view controller containment, this has a few more bells and whistles, more interesting it handles rotation animations better and all the call forwarding to the children controllers that you had to do manually in the first solution.
Check out this link for more details on custom split view controllers:
http://www.mindtreatstudios.com/how-its-made/custom-uisplitviewcontroller-ios/
To answer your question directly: if you make a custom split view controller - yes you can add this as a detail view controller. But watch out, this isn't a UISplitViewController, so just be careful not to use that term so much.
Haven't really tested this, but doesn't this solve your problem?
Create a storyboard file
Drop in a SplitViewController
Delete the DetailViewController
Drop in another SplitViewController
Link the two together using CTRL-drag and select Detail
Set the size of the detail-splitviewcontroller to Detail
????
Profit!
Anyways, not sure if it really works, but give it a try. This is IOS5 though (I think, might try it out with IB).
It'll look something like this:
If you're going to have to write your own class, you might want to first look at https://github.com/mattgemmell/MGSplitViewController for inspiration.

iOS Programming: Understand UINavigationController and the RootViewController

I'm reading Apple doc but I don't understand what a root controller is. The doc says that this is the controller at the bottom of the stack. Maybe, is this the controller that I've push the first time? Anyone can explain this concept?
From Apple doc UINavigationController, I've seen that there is a method called initWithRootViewController
Initializes and returns a newly
created navigation controller.
- (id)initWithRootViewController:(UIViewController
*)rootViewController
What does it mean? Then, is it possible to change the root view controller or not?
Remember that rootViewController isn't a type of object, but a property name. It just happens to be the particular UIViewController instance at the bottom of the stack, as Nubbel said.
Methods like initWithRootViewController are for situations when you want to initialize UINavigationController, and also tell it to "use this VC as the first VC in the heirarchy".
It seems like UINavigationController really doesn't want you to change that property after it's been created, but it looks like ppl have found ways to do it: - Remember to check the comments to see if this is an "approved" method of working.
Just like the Docs and you already said, it is the controller at the bottom of the stack, the first controller pushed to the stack. Subsequent controllers will be pushed on top of the RootViewController. To return to the RootViewController you can use the popToRootViewControllerAnimated:method.
Furthermore, you can't change the RootViewController!

Re-use tableview from different controller: how to split didSelectRowAtIndexPath behaviour?

I'm currently working on my Favorites implementation. In the end, it should work the same as the favorites features in the Phone book on the iPhone.
I've the following set-up (besides other controllers and classes):
TabBarController (named mainTabBarController)
NavigationController with a Tableview (let's call it listNavController)
ViewController with some components for displaying row details (named detailViewController)
NavigationController with a TableView for favorite records (named favoritesNavController)
From the favoritesNavController, I want to select a row (from listNavController) so I can add a new entry to my Favorites tableview.
So, I decided to re-use my listNavController because it has all the functionality I need. Like searching, index, etc.
I've managed to show the listNavController from the mainTabBarController. So no problem here. When I select a row from the listNavController, it displays my detailViewController for that row. Of course, this was expected because that's in didSelectRowAtIndexPath in listNavController.
But, when I launch a listNavController from my favoritesNavController with the help of presentModelViewController, it still shows the detailViewController when selecting a row.
In this case, I want to return the selected row to my favoritesNavController. Then I can add it to my Favorite's list.
So, how do I differentiate this behaviour in code ? Should I use protocols, delegation, etc. ?
Any tips ?
With regards,
Rutger
It turned out that I was looking in the wrong direction.
The solution to the posted question is as follows:
I created a subclass of my listNavController and overrided the didSelectRowAtIndexPath method. Next I presented this new view controller with a navigation controller as a modal view (presentModalViewController).
Finally I set the delegate and a protocol for the subclassed view controller to the initiating class. This way I can present and dismiss the subclassed view controller from the same controller. A much more clean and MVC way to go!

Putting an ADBannerView on top of a UINavigationController

I'm trying to put an iAd banner in an app that is based on a UINavigationController (it's not the standard nav-base app proposed by xcode, cause I don't need the table view).
I'd like to place an ADBanner on its bottom, to be always visible, no matter how the user pops and pushes views.
I studied the iAdSuite example in the apple sample code, but, though it's reported among the "best practices", I don't think it's the best practice for what I need. It basically declares an ADBannerView in the app delegate class and then implements the ADBannerViewDelegate methods for every single view the app needs. That means implementing the ADBannerViewDelegate methods over and over again on every view controller class you need! It doesn't seem too smart... :(
I'd rather prefer to have an approach more similar to what Apple itself does in the tab bar based app, where you have a part of the window always occupied by the tab controller and all the views switching above without affecting the tab bar view below.
You can't directly put an ADBannerView along with the nav controller in the app delegate, because ADBanner needs to be placed in a view controller (you get a runtime error otherwise).
I tried to subclass from UIViewController, implementing the ADBannerViewDelegate in this class, and place it in the rootViewController along with a UINavigationController but I'm not having good luck with this approach...
Has anybody found a good, simple way to to this? Any hint?
Thank you for any help...
You can have just one class for ADBannerViewDelegate, and just one instance of ADBanner itself. When the currently active view changes, remove ADBanner from the old view, add it as a subview to the new view.
EDIT:
to clarify, you don't need each view implement the ADBannerViewDelegate. You only should have one class implement it (that class doesn't have to be a view controller for that matter).
You would also need to maintain a somewhere a property that would point to the currently active view (e.g. you can update that property in your Navigation Controller's navigationController:didShowViewController:animated:, or come up with your own protocol for that if your views appear in a more complex way).
Then in your ADBannerViewDelegate you'd just resize the view currently pointed to by that current view property. The actual view doesn't even have to know it has an ad in it ;)