标签:des style blog http io ar color os sp
http://developer.xamarin.com/guides/ios/user_interface/introduction_to_storyboards/
There are different types of transitions, each giving control over how a new View Controller is presented to the user and how it interacts with other View Controllers in the Storyboard. These are explained below. It is also possible to subclass a segue object to implement a custom transition:
Push – A push Segue adds the View Controller to the navigation stack. It assumes the View Controller originating the push is part of the same Navigation Controller as the View Controller that is being added to the stack. This does the same thing as pushViewController
, and is generally used when there is some relationship between the data on the screens. Using the Push Segue gives you the luxuryof having a Navigation bar with a back button and title added to each View on the stack, allowing drill down navigation through the View Hierarchy.
Modal – A Modal Segue create a relationship between any two View Controllers in your Project, with the option of an animated transition being shown. The child View Controller will completely obscurethe Parent View Controller when brought into view. Unlike a Push Segue, which adds a back button for us; when using a modal segue DismissViewController
must be used in order to return to the previous View Controller.
UIStoryboardSegue
. By overriding the PrepareForSegue
method on the View Controller , When the segue is triggered, the application will call this method.
public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender) { base.PrepareForSegue (segue, sender); var callHistoryContoller = segue.DestinationViewController as CallHistoryController; if (callHistoryContoller != null) { callHistoryContoller.PhoneNumbers = PhoneNumbers; } }
public partial class AppDelegate : UIApplicationDelegate { UIWindow window; public static UIStoryboard Storyboard = UIStoryboard.FromName ("MainStoryboard", null); public static UIViewController initialViewController; public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); initialViewController = Storyboard.InstantiateInitialViewController () as UIViewController; window.RootViewController = initialViewController; window.MakeKeyAndVisible (); return true; } }
public partial class MainViewController : UIViewController { UIViewController pinkViewController; public MainViewController (IntPtr handle) : base (handle) { } public override void AwakeFromNib () { // Called when loaded from xib or storyboard. this.Initialize (); } public void Initialize(){ var myStoryboard = AppDelegate.Storyboard; //Instatiating View Controller with Storyboard ID ‘PinkViewController‘ pinkViewController = myStoryboard.InstantiateViewController ("PinkViewController") as PinkViewController; } public override void ViewDidLoad () { base.ViewDidLoad (); //When we push the button, we will push the pinkViewController onto our current Navigation Stack PinkButton.TouchUpInside += (o, e) => { this.NavigationController.PushViewController (pinkViewController, true); }; } }
An unwind Segue can be used to navigate back through a push or modal segue - for example by dismissing the modally presented view controller. In addition to this, you can unwind through not only one, but a series of push and modal segues and go back multiple steps in your navigation heirarchy with a single unwind action.
We now need to specify an Action method in the View Controllers we wish to unwind to. The method takes a segue
paramater and can be called anything you wish. Make sure the Action String and method name match. Add the following code to YellowViewController:
[Action ("UnwindToYellowViewController:")] public void UnwindToYellowViewController (UIStoryboardSegue segue) { Console.WriteLine ("We‘ve unwinded to Yellow!"); }
[Action ("UnwindToPinkViewController:")] public void UnwindToPinkViewController (UIStoryboardSegue segue) { Console.WriteLine ("We‘ve unwinded to Pink!"); }
Create another Segue, this time from the ‘Unwind to Yellow‘ Button in the PinkViewController to the Scene Exit
On mouse-up the following menu will appear, reflecting the Actions added in the PinkViewController.cs and YellowViewcontroller.cs previously. Select the ‘UnwindToYellowViewController‘ for this Button.
Move to the GreenViewController and repeat the steps above to add an unwind Segue to both buttons. The ‘Unwind To Yellow‘ Button should map to UnwindToYellowViewController
, and the ‘Unwind To Pink‘ Button should map to UnwindToPinkViewController
.
static | FromName(string, Foundation.NSBundle) : UIStoryboard
Factory method to create a UIStoryboard identified by the specified name. |
|
InstantiateInitialViewController() : Foundation.NSObject
Instantiates the initial UIViewController for the UIStoryboard. Allocates a new object every time it is called. |
||
InstantiateViewController(string) : Foundation.NSObject
Instantiates a UIViewController whose corresponding identifier was set in the visual design surface. |
【Xamarin Doc】 Introduction to Storyboards 笔记
标签:des style blog http io ar color os sp
原文地址:http://www.cnblogs.com/jimcheng/p/4162562.html