CosmicMind: How to transition between controllers within a container view using Motion - material-design

I try to implement the Motion feature with transition from one view controller to another when they are used in a container view.
This is what I want to achive:
Using a UIViewController that includes a container view,
Set the container view with a view controller that includes a table
When user selects the row, I want to transition to another view controller and at the same time animate the image in the table view to the image in the new viewcontroller.
So I have the following UIViewControllers:
Main UIViewController, with a containerView
List UIViewController
Detail UIViewController
No I want to cycle, the list view controller with the detail, with a transition of the image.
Kind of like the PhotoCollectionSample, but within a container view.
I have set the isMotionEnabled = true in the main view controller and the view controllers used in the container. I also have set the same motionIdentifier on the imageViews in both view controllers.
The issue I'm facing is how to transition between the controllers. Since I'm not using the UINavigationController or UITabBarController I don't think the animation is triggered.
At the moment I'm transition between controllers by using the implementation found here.
Switching Child View Controllers in iOS with Auto Layout
But I think I have to do it in another way.

Use this method
/**
A helper transition function.
- Parameter from: A UIViewController.
- Parameter to: A UIViewController.
- Parameter in view: A UIView.
- Parameter completion: An optional completion handler.
*/
func transition(from: UIViewController, to: UIViewController, in view: UIView, completion: ((Bool) -> Void)? = nil)
and call it like this:
Motion.shared.transition(from: vc1, to: vc2, in: container)
That should work :)

Related

Show other view wile loading in Xamarin.ios

I am creating a UIViewController which have an animation on it and I want it to be displayed while "loading" or changing views. Is there a way so I can show that view in top of the others while they're doing their business logic and when they're done call in their respectives ViewDidLoad functions, a call to "hide" this facade view?
I think you want to display loading overlay which has your own custom animation and you want to show/hide this loading overlay on top of any View or ViewController. If my understanding is correct then you can achieve this as follows:
Suppose loadingOverlay is your animation view instance.
Assign some unique Tag to this:
loadingOverlay.Tag = 1678;
This can be any number which uniquely identifies your loading overlay view from all other views from UIWindow in any ViewController.
Show:
UIWindow myKeyWindow = UIApplication.SharedApplication.KeyWindow;
myKeyWindow.AddSubView(loadingOverlay);
Hide:
var loadingOverlay = myKeyWindow.ViewWithTag(1678);
//Remove completely
loadingOverlay?.RemoveFromSuperView();
//OR
//Simply hide it
loadingOverlay?.Hidden = true;
Note: If you want to use Hidden property, then you have to make sure that you add this view into UIWindow only once.
So, ideally, anything which you want to display on top of anything,
should go into KeyWindow (UiWindow)
Hope this helps!!

How to implement a SideNavigationViewController into a UIViewController?

A little confused on how to implement this into my main view controller. The example project shows it as a navigation controller, but I wasn't able to add an existing class on a fresh navigation controller or my current UIViewController. I could just be implementing it wrong though. Much appreciation if I can gain some traction on how to work with these.
If you could share some code that would be great.
How things work:
Navigation Controllers
There are currently 4 different Navigation Controllers that each offer their own features. The controllers can be used individually, or together.
SideNavigationViewController
The SideNavigationViewController offers 3 bodies to display content: mainViewController, leftViewController, and rightViewController.
MainViewController
The mainViewController must always exist, and has a facility for transitioning between view controllers using the transitionFromMainViewController method. Using this method is as easy as passing a UIViewController in its first parameter.
sideNavigationViewController?.transitionFromMainViewController(InboxViewController())
There are further parameters that allow for animations, completions, etc... to be set when transitioning between view controllers.
LeftViewController and RightViewController
The leftViewController and rightViewController can be set only once. To make them dynamic, you would need to use another Navigation Controller as its view controller.
NavigationBarViewController
The NavigationBarViewController offers a NavigationBarView along side the ability to manage two UIViewControllers, the mainViewController and the floatingViewController.
MainViewController
The mainViewController is like the SideNavigationViewController's mainViewController, and has a transitionFromMainViewController method that transitions from view controller to view controller in the body portion of the NavigationBarViewController.
FloatingViewController
The floatingViewController is a modalViewController and when set, it pops over MainViewController and NavigationBarView. Setting that value is like so:
navigationBarViewController?.floatingViewController = InboxViewController()
To close and hide the floatingViewController set it to nil, like so.
navigationBarViewController?.floatingViewController = nil
SearchBarViewController
The SearchBarViewController offers a single transitioning mainViewController, as well, has a SearchBarView at the top. Transitioning the mainViewController is like so:
sideNavigationBarViewController?.transitionFromMainViewController(InboxViewController())
MenuViewController
The MenuViewController is another controller that has a mainViewController, which takes the entire screen. Floating above it, is a MenuView that is used to transition between mainViewControllers.
menuViewController?.transitionFromMainViewController(InboxViewController())
Final Notes
These Navigation Controllers can be used in any combination and any amount of times creating a robust and intricate stack of controllers that act like one.
I hope this helps :)

Hiding master UISplitViewController for only certain views

I have a UISplitViewController which has a UINavigationController in the master and a UIViewController in the detail. When the device is orientated into landscape mode I want the normal behaviour to be preserved. I.e. The master gets shown in landscape and hidden in portrait.
However depending what the user clicks in the master depends on which UIViewController is loaded into the detail part of the UISplitViewController. What I would like is for the master to be hidden in landscape mode when a user clicks on a button in the detail UIViewController. The problem is I can't get this to work.
My delegate looks like this (have removed some lines for simpler viewing):
public class SplitControllerDelegate : UISplitViewControllerDelegate {
SplitViewController incomingController;
private bool hideMaster = false;
public override bool ShouldHideViewController (UISplitViewController svc,
UIViewController viewController,
UIInterfaceOrientation inOrientation) {
return hideMaster;
}
public void SetHideMaster(bool value) {
hideMaster = value;
}
}
I then call it from the detail UIViewController like
splitControllerDelegate.SetHideMaster(value);
However nothing changes. I'm unsure of how to make it perform the change? Should the master disappear immediately? What causes the WillHideViewController to fire?
Thanks
Mike
What you're trying to do cannot be done officially. ShouldHideViewController() is called only upon device rotation. So unless you rotate forth and back, your controller won't disappear.
You have various options:
Don't use UIListViewController but some other third party replacement
Use UIViewController containment feature of iOS5 and implement your own split view
Apply a hack to UISplitViewController
About the last point. You should be able to force ShouldHideViewController() being called if you set the Delegate property to NULL and then assign a new delegate. Afterwards, call the WillRotate() method of the split view controller using the current orientation.
I'd go for the 2nd option.
By design you cannot do much with the standard UISplitView, try that third party control :
https://github.com/mattgemmell/MGSplitViewController

What UINavigationController event can be overridden to get access to current view controller?

What UINavigationController event can be overridden to get access to current view controller?
My end goal is to check the current screen in the Navigation Controller to determine whether or not to call SetNavigationBarHidden.
If by "current" you mean "currently visible" you can make use of UINavigationController's VisibleViewController property. Though if you're using MT.D you'll want to cast it out:
var currentViewController = (DialogViewController)myNavController.VisibleViewController
Alternatively you could access the ViewController array directly. Or...you can also subclass DialogViewController and set the NavigationBar.Hidden = true inside the implementation.
How about having a UINavigationController subclass adopt the UINavigationControllerDelegate protocol? Then implement the monotouch equivalent of navigationController:willShowViewController:animated: or navigationController:didShowViewController:animated:. Each of these methods passes a parameter which is a pointer to "[t]he view controller whose view and navigation item properties are being shown." You'll have to remember to make the navigation controller its own delegate.

subclass uitableview already in a UIView

I am trying to implement Leah's "Pull to Refresh" code (https://github.com/leah/PullToRefresh) in to my UITableView. However, I have a UIView, so cannot subclass the tableViewController as is required by this.
My structure is
UIView
- UITableView
So there's a UITableView inside my main UIView. I use a UIViewController obviously - and this cannot really change (I think!)
I have tried to change the class in interface builder to the custom uitableviewcontroller above (the pull to refresh one) but it doesn't let me.
Any ideas on how I can subclass the UITableView - NOT the tableViewController??
Here is how I did it:
Change PullToRefreshTableViewController so that it subclasses UIViewController, NOT UITableViewController. Next, add a UITableView * property called tableView to PullToRefreshTableViewController and synthesize it. Lastly, modify your view controller so that it subclasses PullToRefreshTableViewController instead of UIViewController.
That should give you a working implementation of it.

Resources