UISplitViewController StoryBoards segue to replace detailview - iphone

My storyboard that has the UISplitViewController as the initial view controller. Its master view has a UITableView embedded in a navigation controller, and there is a detail view controller which contains a MKMapView. Clicking on the table cell of the first table view segues into second table view controller.
Clicking on the cell of the second table view segues into second detail view, which is an image view. The segue type is "Replace" with the destination of "Detail Split". Basically, it loads up the image related to the row in second tableView in the detail view.
I am able to navigate back to my first tableview fine. I want to display the first detail view
when the first table view shows up. The reason being that it displays a map view which is related to the contents of the table view. I read quite a bit about it but did not figure out on how to do that. Your help will be really appreciated.

Have you tried adding the following to your first TableViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// existing code if you have any
[self performSegueWithIdentifier:#"Segue ID for your map" sender:self];
}

Related

Segue Not performed

I have a login view controller at the start of the app. Then once the user login is successful I am taking the user to a view which has a table view inside it. I have embedded the table view inside a navigation controller. I have a segue which pushes user to the detail view. However as soon as I click on the row cell, I get the following error.
'Could not find a navigation controller for segue 'Event Details'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.''
But as I said above, there is a navigationview controller which embeds the table view. Whats causing this error?
the flow of the app is as follows
'->Login View NavigatinViewController->(View with a table View inside)->Details'
That looks like you may be missing a view controller.
Specifically, you should have something that resembles:
Login View > Navigation Controller > Table View Controller > Detail View Controller
Assuming you are creating a storyboard, the navigation controller can be easily added by selecting the table view controller and choosing Editor > Embed in > Navigation Controller.
Alternatively, if you want the navigation controller solely for a table view that is embedded within a view controller object, I recommend creating a container view in the view controller to display the table view and associated navigation controller.
To accomplish the latter, drag a container object into the view controller and size it to fit the table view that you want to display. Delete the view controller that the container view automatically creates.
Next, create a table view controller and segue to it from the container view. This segue will be an 'embed' segue. Lastly, you can then embed the table view controller you just created in a navigation controller and add the push segue from the table view controller to the detail view controller.
I think here you not use UINavigationController as a RootViewController.. and you use UIViewController as a rootViewController.. so may be this problem with this error
Just try to Follow this steps for the output..
Drag a new navigation controller into your storyboard - it will by default be attached to a tableview controller
Delete the tableview controller Right click on the navgiation controller, and connect the "Root View Controller" property to your existing view controller
Move the entry point arrow from your view controller to the root view controller
UPDATE:
see this example which through you can put validation and clearly push in your detailview...
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"AddPlayer"])
{
UINavigationController *navigationController =
segue.destinationViewController;
PlayerDetailsViewController
*playerDetailsViewController =
[[navigationController viewControllers]
objectAtIndex:0];
playerDetailsViewController.delegate = self;
}
}

Segue not working for dynamically added subview

I've got a storyboard with view A that is inside a navigation controller. I dynamically add subView B to view A. Subview B has a table view, and the table view cell has a seque (push) to a detail view. When I click on the cell, the prepareForSegue method is called, but the detail view is never displayed. If I switch the seque to a modal, then the detail view gets displayed inside view A, where subView B was.
What I want to happen is the detail view gets pushed onto the navigation controller and when the user hits back on the detail view it goes back to view A, with the subview B embedded.
Below is the code I use for adding the subview:
if(!self.homeViewController){
self.homeViewController = [self.storyboardinstantiateViewControllerWithIdentifier:#"HomeView"];
}
if(self.currentViewController != self.homeViewController)
{
[self.view insertSubview:self.homeViewController.view belowSubview:self.tabBar];
[self.currentViewController removeFromParentViewController];
}
self.currentViewController = self.homeViewController;
Without seeing your code (and storyboard) this may be hard to diagnose. I have found, however, that sometimes it's a chore to get segues to work properly with dynamically loaded content. In some cases I have found that using the pushViewController:animated: and popViewController:animated methods of the UINavigationController can be a better approach. You should be able to access the UINavigationController by through UIViewcontroller.navigationController.

pushViewController from Prototype Cell

Quite simply, how do I push a new view controller from a prototype cell within a storyboard? I have a tableView reading data from a plist file, and its one default prototype cell on the storyboard. Then, I have another view controller in the storyboard I need to link to the tapping of a cell on the table view. How can this be accomplished?
Simplest thing would be to Ctrl-click on the prototype cell and drag the line onto the view controller that you want to transition to. It should prompt you for the type of transition—"push" transitions cause the new view controller's view to slide in from the right; "modal" transitions cause the new view to slide in from the bottom. Assuming you're using a navigation controller, the navigation bar should configure the back button automatically. You shouldn't need to write any code to achieve the behavior described in your question.
In your storyboard, link your prototype table view cell to your view
controller with a segue. Make sure to give the segue an identifier in
its Attributes Inspector.
In your TableViewController class,
implement - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
In the prepareForSegue: method, get the NSIndexPath of the row the user tapped with [self.tableView indexPathForSelectedRow]
Use the indexPath to get whatever data you need from your plist. Configure the view controller by using the destinationViewController property of the UIStoryboardSegue parameter passed into prepareForSegue:.

Create TableView in the same View

I want to know esque I can do when I click Finish"-(IBAction)textFieldDoneEditing:(id) sender " on the keyboard, I view a tableView
You can create a view controller which contains the table view and populate it when the user finishes editing and then show the view controller's view as subview if you want it on the same view controller or you can also push it in the navigation stack if you have one.

How do I have a Tableview go to another tableview

Right now I have an indexed tableview that goes to a detail view but i want it to go to another tableview then a detail view.
Any thoughts?
Use a UINavigationController with the first table view as its root view controller.
Implement the tableView:didSelectRowAtIndexPath: method of the table view's delegate to create the second table view (from a nib or programmatically, doesn't matter, as long as it's an instance of UITableViewController), then call the navigation controller's pushViewController:animated: method with the new controller.
Then, from the second controller, present your detail view as you are doing so already.
See also:
Using Navigation Controllers
Navigating a Data Hierarchy with Table Views
SimpleDrillDown sample project (may require registration)
The same way you would go to a detail view, but instead of transitioning to a view transition to a TableView.