How to animate a detailViewController view without UINavigationController? - ios

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.

Related

Hide UINavigationBar 3D touch

I am trying to 3D peek and pop items in a UITableView. Everything works fine, except the target ViewController has a UINavigationBar which also shows.
I added my UINavigationBar to my ViewController code through Interface Builder and set self.navBar.isHidden to true which hides the UINavigationBar, but it leaves empty space equal to the size of the UINavigationBar.
Does anyone know how to hide the UINavigationBar properly?
Note: I am not using a UINavigationController, I simply added the UINavigationBar to my ViewController by drag/drop.
the target ViewController has a UINavigationBar which also shows
Use a real UINavigationController plus UITableViewController (as its root view controller). This is an excellent way to have a navigation bar even if you never intend doing any navigation.
Here's a big advantage of doing that: You don't even need to hide the navigation bar when you peek! Use the UITableViewController alone as the peek navigation controller, and the UINavigationController when you pop. Thus, the preview won't have any navigation bar but if the user presses all the way and you do the real transition, the new view controller will have the navigation bar. Remember, no law says that the peek view controller must be the same as the pop view controller!

Using UITabBar outside of the rootViewController

My application has a sequence of UIViews (with a UINavigationBar) that lead up to a UITabBarController View. These tab bar views should each have UINavigationBars as well. In my research, I have found that due to the nature of UITabBarControllers they should be the rootViewController and that they should not be wrapped in a previous view controller's NavigationBar, as this will lead to problems in the Navigation stack. I've read into seguing from UIView to UITabBarController using the modal method rather than a push, as to to remove the UINavigationBar, but I can't seem to pass data through the TabBarController and NavigationController to the Tab root view through the segue. I get a selector error.
I guess what I'm looking for is advice on a sound approach to take for using a UITabBar where each child view needs NavigationBars and where the UITabBar is segued to from a previous UIView.
Thanks!

Push navigationController while persisting a UIView

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

Presence of UIToolbar affecting layout of view controller's view

I have a UIPageViewController subclass that displays 1 view controller at a time. The displayed view controller has a scrollview. This allows the user to scroll left/right to go to a new page, or up down to view content larger than the screen's height. The UIPageViewController subclass is embedded within a UINavigationController, and the navBar's toolbar is visible.
This UIPageViewController subclass can be accessed from two different parts of my app.
In my first viewController, the toolbar is hidden. Tapping on an element in this view controller loads the UIPageViewController, and everything looks fine.
In my second viewController, the toolbar is visible. Tapping on an element in this view controller loads the UIPageViewController, but my content (the pageViewController's viewController) is pushed down a bit from the navigation bar. As soon as I interact with the scrollView though, the view automatically adjusts to correctly sit right below the nav bar.
I am running this on iOS7, but I'm not sure if that has any relation.
Why is my view controller loading differently when coming from two different parts of the app, one with the toolbar showing, one with it hidden?
If your app works well on iOS6, but not on iOS7, try to set NO to UIPageViewController(UIPVC)'s automaticallyAdjustsScrollViewInsets property.
UIPVC seems to have a scrollview inside. On iOS7, UIViewController's automaticallyAdjustsScrollViewInsets property is set to YES in default. I think it doesn't work well if it is embedded in UINavigationController.
In my case, I created custom UIPVC and place the following code in [viewDidLoad] method.
self.automaticallyAdjustsScrollViewInsets = NO;
I was finally able to properly align an embedded UIPageViewController in a NavController, which itself is inside a TabBarcontroller. I did so by programmatically creating the pageViewController inside a dummy "rootviewcontroller", following the example given in the default Xcode "New Project" called "Page-based Application".
In my case, the following storyboard layout produce the error: TabBarController -> NavController -> UIPageViewController (scroll-horizontal) -> ContentViewController
I changed my storyboard layout to: TabBarController -> NavController -> CustomRootViewController
The CustomRootViewController instantiates a UIPageViewController and saves it as a member property. CustomRootViewController becomes the DataSource and Delegate for its PageViewController. Follow the default Xcode "New Project" called "Page-based Application" for an example of how to setup the RootViewController.
Unfortunately, this whole issue appears to be caused by a bug in Storyboard when you are using the drag-and-drop "UIPageViewController", with scroll-horizontal transition-type, embedded in a navController (and/or tabbarcontroller). FYI - In the pageViewController's viewWillAppear, I tried resetting the frame of the pageViewController and the contentViewControllers each to (0,0) with size matching the device, and yet the view of the pageViewController's initial viewController would always be shifted-down by what appeared to be the height of the tabbarcontroller in which it was embedded. Here are a few observations for those who wish to pursue this issue further:
In viewDidLoad, you can set the Frame of the pageViewController's initial view to offset the layout-error. But then you might have to deal with different layout-corrections for different devices in different orientations, and that could be a headache down the road.
In Storyboard, setting the pageViewController's transition style to "page curl" resolves the layout issue. So therefore I am certain that the layout issue resides in page-scroll, which is set upon instantiation. Instantiation by Storyboard will produce the layout error, but instantiation programmatically in my CustomRootViewController is error-free.

How to add a subview to a UINavigation Controller without losing navigation bar?

I have a SplitViewController which has two UITableViewControllers - one master/root one detail. Everything works swimmingly.
I have a UIView which is shown on the detail view controller before the user selects an item in the root view controller. It's set up like this:
[self.navigationController.view addSubview:makeSentenceHelperView];
[self.navigationController.view bringSubviewToFront:makeSentenceHelperView];
The detailViewController is set up like so:
UINavigationController *detailNav = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
Where detailViewController is a subclass of UITableView.
The problem is that this subView hides the buttons and navigation bar from the detail view controller's navigation bar - which is a problem when you launch the SVC in portrait mode (there's no way to select a root item with the root popup).
How can I present the view inside the navigation controller, so that the navigation bar and buttons appear in the detail view?
Don't make detailViewController a subclass of UIView, instead go with UIViewController. So your splitView array will contain a instance of UINavigationController(rootVC) and other of UIViewController (detailVC).
Add a toolbar on the top of detailViewController and in landscape mode left side will be covered by your UITableView of rootVC and you will be able to see toolbar where you can add some button to its right side (will probably serve as navigation bar..:) . Rest of the things can be handled by UISplitViewControllerDelegate.
To fix this I added a UINavigationController to my helper UIView, and added a UIButtonBarItem to call the popover for selecting a new item in the master view. It seems really simple in retrospect. The only tricky bit will be making the UIButtonBarItem hide when in landscape.

Resources