iPad can navigation controller be put inside popover? - ipad

I have made popover displaying UITableViewController, that is used for navigation. What I am interested in to know is - can you use navigational controller inside popover. Lets say you have table where each row transitions to new view. Can this be used in conjuction with popover view, and if so, can you provide some working examples?

Yes, it's very much possible. Firstly create the object of your table class.
TableClass *tblClassObj = [[TableClass alloc] init];
Then create the navigation controller object.
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tblClassObj];
Then use this navigatin controller for your pop over controller.
UIPopoverController *samplePopOver = [[UIPopoverController alloc] initWithContentViewController:navigationController];
...
Don't forget to release the objects.

Related

pushViewController and Split View Controller — any workaround?

So, I'm programming a universal application, and with iOS 8, it seems easiest to create split views to ensure that everything properly appears on iPhones and iPads. The dominant UI component in my app is a tab bar.
One of my tabs is a tableview that acts as a menu. I want to push a split view controller from didSelectRowAtIndexPath like so:
[self.navigationController pushViewController:ytSplitViewController animated:YES];
This returns an error: Split View Controllers cannot be pushed to a Navigation Controller
I can modally present the view controller, but this hides my tab bar and makes my interface more convoluted (an undesirable result)
[self.navigationController presentViewController:ytSplitViewController animated:YES completion:nil];
Is there a workaround that I can employ to present my SplitViewController within my UI paradigm? More clearly, can I essentially push my split view controller using a different method?
In case it's relevant, this is how I create my split view:
YTTableViewController *ytTableViewController = [YTTableViewController new];
UINavigationController *ytNavigationController = [[UINavigationController alloc] initWithRootViewController:ytTableViewController];
YTDetailViewController *ytDetailViewController = [YTDetailViewController new];
UINavigationController *ytDetailNavigationController = [[UINavigationController alloc] initWithRootViewController:ytDetailViewController];
NSArray *ytViewArray = [NSArray arrayWithObjects:ytNavigationController, ytDetailNavigationController, nil];
UISplitViewController *ytSplitViewController = [UISplitViewController new];
ytSplitViewController.viewControllers = ytViewArray;
ytSplitViewController.delegate = ytDetailViewController;
Split view controllers are meant to be presented as root objects, not pushed in the hierarchy.
Of course, you can always trick it, by using view controller containment. Create a UIViewController subclass, add the split view controller as a child controller, and push the parent controller. This should work.

Add a second UINavigationController

I have my first NavigationController set up with root viewcontroller - PhotoViewController, It's a collectionView with grid of images. When image is selected I wan't to present a second navigationController with root controller - DetailViewControler.
My first navigationController is set up in appDelegate. I really don't understand how and where should I create the second. I'm not using IB. At the moment I have this in my DetailViewcontroller viewDidLoad:
DetailViewController *detailView = [[DetailViewController alloc] init];
self.detailController = [[UINavigationController alloc] initWithRootViewController:detailView];
But when i'm trying to push a new controller, nothing happens. I guess that my code is in wrong place.
When I try to present second controller modally from my PhotoViewController, I have an error(trying to present nil viewController).
The common idea is to have a single navigation VC that contains -- and lets you navigate between -- other VCs. In the situation you describe, you wouldn't create another navigation VC. Instead, create just the detail VC and push that onto the existing navigation VC...
// assuming self is a view controller contained by a navigation controller
self.detailController = [[DetailViewController alloc] init];
[self.navigationController pushViewController:self.detailController animated:YES];
Use a parent view controller as your initial view controller and add the navigation controllers as children, then transition between them. See this blogpost that I wrote: http://sketchytech.blogspot.co.uk/2012/09/container-view-controllers-parent-view.html

Adding a third Tab in Tab bar project

im new to iphone coding and i would like some help with a tab-bar project as i found on www.fuelyourcoding.com
He is creating a custom tabbar. He can then change color of the tab-bar instead of the standard grey color.
How can i Add a third tab? I have tried to create a "ThirdViewController" as the project contained a first and a second-viewcontroller. I've also tried to copy all the information i thought could affect the tabs, and inserted "ThirdViewController", where it previously said "SecondViewController" and so on.
It's hard to describe, but here is the link if someone would be kind to have a look at it.
http://fuelyourcoding.com/files/files.zip
Thanks!
In general, you create a tab bar controller and three view controllers. You add these three view controllers to the tab bar controller and add the tab bar controller as the root view controller of the app delegate. There's not a lot that can go wrong with this idea, but if you can show more code, that will be great.
Here's the example:
ViewController1 *v1 = [[ViewController1 alloc] init];
ViewController2 *v2 = [[ViewController2 alloc] init];
ViewController3 *v3 = [[ViewController3 alloc] init];
self.tabBarController.viewControllers = #[v1, v2, v3];
self.window.rootViewController = self.tabBarController;

How to get Navigation bar inside UIPopover Controller

I am using a uipopover controller with navigation bar.Actually i want to have navigation bar inside the popover controller. i tried changing the background color of the navigation controller but it didnt look as i expected.The navigation bar buttons seems to be attached with the popover corners.Please find the screenshot attached.Below is my code which i used to create the popover.
WLViewBookmarkViewController * viewBookmarkViewController = [[WLViewBookmarkViewController alloc] initWithStyle:UITableViewStyleGrouped];
viewBookmarkViewController.delegate = self;
UINavigationController *viewBookmarkNavController = [[UINavigationController alloc] initWithRootViewController:viewBookmarkViewController];
viewBookmarkNavController.navigationBar.backgroundColor = [UIColor colorWithRed:9/255.0 green:135/255.0 blue:46/255.0 alpha:1.0];
self.bookmarkPopoverController = [[UIPopoverController alloc] initWithContentViewController:viewBookmarkNavController];
[self.bookmarkPopoverController presentPopoverFromBarButtonItem:bookmarkButtonItem permittedArrowDirections:UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp
animated:YES];
Please suggest if there are any other way to achieve this.
I would init the UIPopover controller with the UINavigationController directly
self.bookmarkPopoverController = [[UIPopoverController alloc] initWithContentViewController: viewBookmarkNavController];
Also try settings the content size of the popover by overriding -contentSizeForViewInPopover in the viewBookmarkViewController class to return a CGSize, you should get neater results this way.
I created a Xib in where i had a view for the controller which i had to add inside the popover.i added a table view and a navigation bar into the view.

Initializing root view controller with myViewController / Using split view(sliding navigation) controller

I'm working on adopting slide (split) view controller to my project.
JT, DD, ZUUI, JW, ECS.....
All these sources suggesting initialize my root view controller in appDelegate.
Something like this....
MyMainViewController *controller = [MyMainController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:Controller];
.........
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
Problem is I can't make my view visible, my app show blank page only with a empty navigation bar.
I customized my main view using AQGrid, is this causing a problem?
My view looks different to storyboard look. (because I customized it.)
So when I do initialize I'm using "self.storyboard initialize......method".
But in appdelegate, I can't use that method.
Simply, I can't make this view hierarchy because when I initialize my view it is not visible.
ZUUIRevealController is parent of:
UINavigationController is parent of:
FrontViewController
If you are using a storyboard, don't do any of that. Instead, choose your starting view controller from the storyboard and check the "Is Initial View Controller" in the Attributes inspector.

Resources