Dismiss Parent View Controller iOS 5 - xcode

Im going to a new view using the following code:
UIStoryboard *storyboard = self.storyboard;
finishViewController *finished = [storyboard instantiateViewControllerWithIdentifier:#"finishViewController"];
[self presentViewController:finished animated:NO completion:nil];
Once the new view is loaded the previous view controller is still functioning behind it. Is there a way I can erase it from memory?
Ive tried:
[self.presentingViewController dismissModalViewControllerAnimated:YES];
and
[self.parentViewController dismissModalViewControllerAnimated:YES];
I thought this would be pretty straight forward. T
Thanks

You're presenting a modal view from the parent view controller.
It sounds like what you really want to do is push or segue the finished view controller from the parent view controller.
If you are determined to dismiss / erase the parent view controller, why not first pop the parent view controller and then push/present the finished view controller.

Try using [finished makeKeyAndVisible] it'll make your new controller the only controller.

This can't be done. If you dismiss the parent you'll dismiss both of them.

Related

Swift back button with segue show not showing

So I tried everything with showing up the back button but it just won't work
This is how i arrange my View Controllers Used segue show from view controller to site view controller
And here is the site view controller that isn't showing back button
I even tried adding NavigationBar and a button with this function
self.navigationController.popToRootViewControllerAnimated(true)
Also failed
Update:
I tried this in both view controllers it's returning nil
in viewDidAppear and viewWillAppear
print(self.navigationController?.restorationIdentifier)
Once I got the same problem, when I was try to use view property of my UIViewController before it loaded properly. This caused problems with loading my navigation bar items. In fact, you should not touch view property until viewDidLoad method is called. Check, maybe it is your case, maybe you use view property in prepareForSegue method or in observers?

iOS8 UISplitViewController: How to switch to master view in compact width window?

My root view controller is an UISplitViewController, which has a UITableViewController as master view controller. On iPhone (compact width), it looks like a UINavigationController.
Tap a cell to show detail view controller
Tapping the trash button would delete the current note. My problem is how to go back to the master view after that? Since it's an UISplitViewController, it can't pop the current view controller as UINavigationController does.
I had a similar problem and finally found a solution. As I understand it, when in compact width, the detail navigation controller becomes a view controller of the master navigation controller. So all you have to do is:
Determine if only one view is present by checking the split view controller's collapsed property. If it isn't collapsed (e.g. on iPad), you're already showing the table view in addition to the detail view.
If it is collapsed (e.g. on iPhone) get a reference to the master navigation controller via the detail navigation controller and have it pop to its root view controller which, in this case the your table view controller.
This is the code I use in my detail view controller. In your case I think you just need to add this code to the button action in your detail view controller:
if splitViewController!.collapsed {
let detailNavController = parentViewController as UINavigationController!
let masterNavController = detailNavController.parentViewController as UINavigationController!
masterNavController.popToRootViewControllerAnimated(true)
}
Good luck!

NSFetchedResultsController running after performing push on UINavigationController

I am using an NSFetchedResultsController with my tableview inside of a UINavigationControler. When an item is tapped on the tableview I perform a 'push' and pass a specific entity in the prepareForSegue in order to show more detailed data about that record.
In the detail view controller the model can be edited. There appears to be a lot of lag when I change the model. And I noticed that the tableView:cellforRowAtIndexPath: on the previous view controller is being called.
I've tried using performSelectorInBackground: but doesn't seem to help much.
Once push a view controller, isn't the view controller below not supposed to run? Has anyone been able to overcome this lag issue?
Thank you
I actually ran into this tonight and solved it by adding a new bool property on my view controller to store when my VC is visible.
#property (nonatomic, assign, getter = isVisble) BOOL visible;
Then I check at the top of FRC delegate methods if the view is visible or not.
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
if (! self.isVisble) {
return;
}
[tableView beginUpdates];
}
This seems to help stuttering and performance when the VC with the FRC has been pushed behind other VCs.

Switching between view controllers without using navigation controller stack

i am creating my first app.i have multiple view controller stack in my app. i want to switch view controllers, so i am using this method:
wallViewController *dvc = [[wallViewController alloc] initWithNibName:#"wallViewController" bundle:nil];
dvc.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:dvc animated:YES];
[dvc release];
its working fine. but its reloading view controller,like its calling viewdidload each time,but i want to show the previous state of parent view controller as in navigation controller.Please help me.

Tableview reloadData is not being executed -- sometimes

I have a view controller that is called from 2 different places.
1) I call it from a root controller. It is shown and populated. The add button works perfectly. I open a modal form, get the information and return it to the view controller via it's delegate.
- (void)itemsAddViewController:(AddItemView *)itemsAddViewController didAddItem
(OrdersDetails *)orderDetail;
{
if (orderDetail) {
[orderDetailItems addObject:orderDetail];
}
[self fetchOrderDetails];
[lineItemsTableView reloadData];
[self dismissModalViewControllerAnimated:YES];
}
However, when I call it from another view (on the right side of the split view), this same code does NOT reload the table. It adds the data -- if I leave the form and come back, the data is there, but the tableview is not being refreshed. When I step through the code, it gets the the line, but then goes over it like it doesn't see it.
When a modal view controller is presented over the view controller containing -itemsAddViewController:didAddItem: the underlying controller's view is not visible and will therefore be unloaded if the controller receives a memory warning.
As a result your view may not be loaded and your lineItemsTableView outlet may be nil when you call -itemsAddViewController:didAddItem:. Your call to reloadData would need to move to -viewWillAppear: to avoid assuming that your controller's view can have a persistent state when it is not visible.

Resources