I am testing the UISplitViewController but I'm having trouble connecting the ThirdDetailView which is a UINavigationController with its TableTestView. The ThirdDetailView does display but its not rendering the TableTestView. I put a few break points in TableTestView but it doesn't hit it. How Can I wire up the TableTestView to the ThirdDetailView? I tried using the AppDelegate but I just can't seem initiate a UINavigation subview to the split view controller.
Below is my setup
AppDelegate
RootView
FirstDetailView - UIViewController
SecondDetailView - UIViewController
ThirdDetailView - UINavigationController
TableTestView - UIViewController
Related
I'm trying to get a reference to my detailViewController in application didFinishLaunchingWithOptions: method. But here I am faced with a problem.
I have next Views structure is storyBoard (for iPad):
UISplitViewController --> UINavigationController --> UITableViewController --> detailViewController
I created segue with "push" style between UITableViewControllerCell and detailViewController
Screenshot: http://picturepush.com/public/13071076
I'm trying to get a reference to detailViewController in this way:
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
DetailViewController *detailViewController = [navigationController.viewControllers lastObject];
But in result I got reference to my UITableViewController, instead of acceptable
DetailViewController. The navigationController.viewControllers count is 1 but there should be 2 (I think so).
I hope for your help.
Since you created a segue with push style, the detailViewController will only be loaded after you tap on a table view cell. It will not be loaded on the app didFinishLaunchingWithOptions method.
I would suggest you try to make the detailViewController as a property in your table view controller.
#property (nonatomic, strong) UIViewController *detailViewController;
Then in your app didFinishLaunchingWithOptions method, you can access the property:
UITableViewController *tableViewController = [navigationController.viewControllers lastObject];
DetailViewController *detailViewController = tableViewController.detailViewController;
But you will need to avoid using perform segue function and push the detail view controller whenever it is needed with the usual pushViewController method.
[self.navigationController pushViewController:self.detailViewController animated:YES];
I am presenting a popover with my viewcontroller:
UIBarButtonItem *barButton = (UIBarButtonItem*)sender;
SettingsViewController *settingsViewController = [[SettingsViewController alloc] initWithNibName:nil bundle:nil];
[self presentPopoverFromBarButtonItem:barButton andController:settingsViewController andSize:CGSizeMake(RECT_POPOVER_SETTINGS.size.width, RECT_POPOVER_SETTINGS.size.height)];
and inside this view controller I have a button that pushes another view controller.
AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:anotherViewController animated:YES];
Now in this view controller I have an action, and when it's done I do:
[self.navigationController popViewControllerAnimated:YES];
Now the strange behavior is that when I pop the view controller, the
viewWillAppear
method gets called in SettingsViewController, then the breakpoints come back to pop method inside my anotherViewController.
This is a universal App so I am using this same setup on the iPhone, but without the initial UIPopOverController. This is functioning properly in the iPhone (with no popovers, pop method gets called first, then viewWillAppear), but on the iPad the viewWillAppear gets called first, then pop.
So my question is, can somebody explain why this is happening?
Thanks.
I create a split view project, on the iPhone's storyboard, i drag a bar button item to the navigation right and change the style Add, and i drag a view controller to the storyboard, so i use control-drag to build the link, and change the uiviewcontroller's custom class "AddViewController", when i run the project and push the DetailViewController, it is black view.
And i have input the code on the AddViewController.m
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:#"AddViewController"];
[vc setModalPresentationStyle:UIModalPresentationCurrentContext];
[self presentModalViewController:vc animated:YES];
}
i found the reason
On the my create "AddCreateViewController", i should comment the function.
- (void)loadView
{
// If you create your views manually, you MUST override this method and use it to create your views.
// If you use Interface Builder to create your views, then you must NOT override this method.
}
I have tabbar + navigation app. I call filterModalController:
[self.navigationController presentModalViewController:filterModalController animated:YES];
It appeared OK. Then I want to push officeController.
[self.navigationController pushViewController:officeController animated:YES];
But officeController didn't appeared. What is wrong?
My understanding is that modal view controllers are not meant to push other view controllers, so you may want to think about the hierarchy of views you are using. Modals are meant to return to the parent view controller. You may need to call
[self.navigationController dismissModalViewControllerAnimated:YES];
before you push the officeViewController.
When I ran into this, I ended up pushing a Navigation controller as the modal view controller, with the 'filterModalController' as the root view controller. Since you already have a navigation controller, this may make things too confusing.
UINavigationController* filterNavController = [[UINavigationController alloc]
initWithRootViewController:filterModalController];
// Display the nav controller modally.
[self presentModalViewController:filterNavController animated:YES];
[locationNavController release];
Then the filterNavController can push your officeController.
I can't show a UIToolbar that was at the bottom of a view, where the view pushed a navigation controller and then popped back to the view using the back button.
In a NIB I've created:
UIViewController RootViewController containing a
UIView containing a
UIToolbar at bottom of UIView
In RootViewController I create next UIViewController, NextViewController, within which I create a NavigationController:
UIViewController RootViewController containing a
UIViewController NextViewController containing a
NavigationController
In NextViewController I can see the UIToolbar from RootViewController. When I pop back to NextViewController, using the back button, from the NavigationController I can no longer see the UIToolbar from RootViewController. Does anyone know how to make the UIToolbar visible?
One approach I thought would work was to get a pointer to the UIToolbar and add it as a subview to the navigation controller as:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
RootViewController *rootViewController = appDelegate.rootViewController;
UIView *rootViewUIView = rootViewController.view;
UIToolbar *rootViewUIToolbar = rootViewUIView.toolbar;
[self.navigationController.view addSubview:rootViewUIToolbar];
But I get the error: "Request for member rootViewUIToolbar in something not a structure or a union" for the line:
UIToolbar *rootViewUIToolbar = rootViewUIView.toolbar;
Any ideas on how to show the toolbar after popping back to the root view from the navigation controller using the back button?