Push navigationController while persisting a UIView - ios

I am using a navigation controller to push from vc1 to vc2. I have a mapview in vc1 which I want to also have replicated in vc2, so that it appears that essentially only a new navigation bar animated into view and the mapview didn't ever move during the transition to vc2.
I've tried setting vc2.mapview = self.mapview in vc1 prepareForSegue, but I didn't like the transition. I've tried custom modal segues too to overlay the mapview with a clear background in vc2, but then the map won't detect touches.
This is similar to the problem Tariq had here (iOS - pushViewController without sliding Background Image), but for me I need to be able to still interact with the mapview in vc2.
Any suggestions at all are welcome, thanks!

Try to find a way to split window in 2 view controllers. One on top and one bottom.
The top one should have navigation controller while the bottom one only the map.
Make some links between them and you're done.
Or you can use UITabBarController

Related

How to pop UIViewController when no NavigationController?

My initial scene has a navigation controller embedded. This scene links to a UITableViewController scene. The tableview scene doesn't know anything about the navigation controller.
In the tableview scene, I've added a navigation bar and left button called back. How do I get back to the previous scene?
I have the following action associated with the back button:
self.navigationController?.popViewControllerAnimated(true)
But it doesn't do anything because self.navigationController is nil.
If your navigationController is nil, then your scene must have been displayed modally, not pushed onto a nav controller. Instead of popping it, you have to call dismissViewController on it.
A better approach than using a left button item to navigate is to use the nav bar's built-in functionality by setting a custom backIndicatorImage and mask.

InteractivePopGestureRecognizer not animating correctly

I have rather complicated structure of my UIViewControllers, so interactivePopGesturerecognizer behaves strange.
First, my VC hierarchy is as follows: I have a UINavigationController which is in AppDelegate's rootViewController VC. Then I push a VC which servers as a placeholder for 5 VCs on same level, i.e. those VCs are siblings which I use as VCs in infinite horizontal scroll system. I add their views to pushed VC. Now, each of those 5 VCs have UITableView and after pressing rows, those tables push details VC on stack. Details VCs are being animated just fine when being pushed to stack. Even when I hit back button on details VC, I see parent UITableView animating in the background. The problem arises when I try to swipe the details VC to pop it off stack. Then I get this, there is no UITableView in the background that animates.
So far, I've done this:
- in my AppDelegate.m I enabled interactive pop gesture navigation.interactivePopGestureRecognizer.enabled = YES;
in my details VC I set delegate self.navigationController.interactivePopGestureRecognizer.delegate = self;
When the animation finishes, i.e. details VC goes right off the screen, my parent VC with table magically shows up. This doesn't happen if I press button, in that case, that UITableView animates from left and stays in position.
I presume that since I'm having situation with horizontal scroll UINavigationController loses it's position after I scrolled to another UITableView so parent table is someplace else. But how come when I press the back button, I can see that table animating from left?
I also tried to explicitly add UITableView of current VC that is on screen to navigation stack by pushing it, but the problem arose when I tried to pop it of stack and show it again, it stayed invisible.
I don't want to have multiple UINavigationControllers because when I swipe them inside UIScrollView, I want my bar to be fixed in position.
So, main question is: how to have the same visual behaviour with interactivePopGestureRecoginzer as I get with back button for free (animated parent UITableView), considering the fact that I have 5 sibling VCs that are not part of navigation stack, but merely their views added to parent VC which is on navigation stack?
Thanks!

Keep UIView while animating navController

How can I animate in a new uinavigation controller but keep the same uiview in the window?
I've seen this done in the opposite - a navController stay in place while a container view changes a view controller as a child view controller, but I want the opposite:a main view, a mapview, to remain in the window at all times while a new vc2 slides in from a push segue which will show a different navBar title and uibarbutton items. This is important because I need the mapview from VC1 to replicate in VC2, or to that effect.
Can this be done and how? Thank you for suggestions all,
It would probably be better to do this without a navigation controller. You can create a custom container controller with a navigation bar at the top. You can add vc2 as a child of your container controller, remove the map view from vc1, add it to the view of vc2, and remove vc1 from the container controller. This would all be done with no animation, so the user shouldn't see anything happening in the main view. You can call pushNavigationItem:animated: on the navigation bar to animate in the new navigation item.

iOS 7 universal background UIViewController

I am trying to set up a UIViewController in my app which always remains in the background of all other UIViewControllers. What I want it to do is display a repetitive animation continuously in the background, unaffected my transitions and navigations in the UIViewControllers in the foreground. Can anybody suggest a good method to do this?
You could create your own UINavigationController and add your animation view to its background in the viewDidLoad method
self.view insertSubview:myAnimatedView atIndex:0
And make sure that your other viewcontollers are transparent.
See also https://stackoverflow.com/a/13096911/443270
Make a view controller that will have your background view and animation as your root view controller. Then make the view controller that you want to control the rest of your app (we'll call it your navigation controller). Add the view of your navigation controller as a subview of your background view controller.
edit:
You can't do this with tab bar controllers as they must be the root view controller.
start with a subclassed UINavigationController with your animation on ViewDidLoad
push the viewcontrolelrs on this subclassed NavController
example from my github page
https://github.com/mako34/backgroundNavController

How to animate a detailViewController view without UINavigationController?

In an iPad app, I have a tableView as a subview of a top level viewController - let's call it topVC. The tableView is controlled by a dedicated viewController, tblVC, which is a property of topVC. I need the tableView to support iPhone-style detailView navigation.
Setting up a UINavigationController property in the topVC.xib in IB, with tblVC wired as the rootViewController, didn't work, so I set it up the UINavigationController programmatically in topVC viewWillAppear: initializing it with tblVC as the rootViewController, and setting its view as a subview of topVC. This functioned as desired but upon rotation to landscape orientation, the navigationController's navigationBar would pop to the top of thetopVC view.
Is it possible to manually achieve detailView navigation with basic iPhone-style slide-in animation without UINavigationController, using UINavigationBar and UINavigationItem? I thought of setting the detailView out of the frame of the tableView and sliding it in manually, but that only made it appear over another subview and slide into the tableView. How to do this?
You could consider using a popover view controller, and host inside it a standard UINavigationController, with your UITableViewController inside that.
Otherwise you're gonna have to roll your own nav-controller. I've found that it's a real PITA to change/affect some of the innate behaviors you're seeing, like repositioning on rotation.

Resources