http://developer.xamarin.com/guides/ios/user_interface/introduction_to_storyboards/

Segues

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.

  • Custom – Any custom Segue can be created as a subclass of UIStoryboardSegue.
  • Unwind – 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 hierarchy with a single unwind action. To understand how to use an unwind segue in the iOS, read the Creating Unwind Segues recipe.
  • Sourceless – A Sourceless Segue indicates the Scene containing the Initial View Controller and therefore which View the user will see first.

Transferring Data with Segues

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;
}
}

Instantiate Storyboards Manually

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);
};
} }

Creating an Unwind Segue

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 .

UIKit.UIStoryboard: Method Members

static FromName(stringFoundation.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 笔记的更多相关文章

  1. 机器学习介绍(introduction)-读书笔记-

    一,什么是机器学习 第一个机器学习的定义来自于 Arthur Samuel.他定义机器学习为,在进行特定编程的情况下,给予计算机学习能力的领域.Samuel 的定义可以回溯到 50 年代,他编写了一个 ...

  2. OpenStack Network --- introduction部分 阅读笔记

    Basic Networking 1.混杂模式(promiscuous mode):当网卡被配置为混杂模式时,它们会将所有的frame传递给操作系统,即使MAC地址不匹配. 2.交换机(switch) ...

  3. 人工智能头条(公开课笔记)+AI科技大本营——一拨微信公众号文章

    不错的 Tutorial: 从零到一学习计算机视觉:朋友圈爆款背后的计算机视觉技术与应用 | 公开课笔记 分享人 | 叶聪(腾讯云 AI 和大数据中心高级研发工程师) 整    理 | Leo 出   ...

  4. 第一周课堂笔记2th

    上课笔记2th https://mubu.com/doc/2gxvIvVLG0(老师笔记网址) 1.     python python运行过程 把源代码转化成字节码(机器不能识别) 也可能不产生py ...

  5. MongoDB学习之--增删改查(1)

    本文是对mongodb学习的一点笔记,主要介绍最简单的增删改操作,初学,看着API,有什么错误,希望大家指正:(使用官方驱动) 1.增 增加操作是最简单的,构造bsonDcument插入即可: 方式1 ...

  6. python merry -- error handling in the real world

    参考: https://www.youtube.com/watch?v=8kTlzR4HhWo https://github.com/miguelgrinberg/merry 背景 本文实际就是把 d ...

  7. CUnit的用法

    转自:http://blog.csdn.net/scucj/article/details/4385630/ CUnit下载地址: http://sourceforge.net/projects/cu ...

  8. CAS单点登录之mysql数据库用户验证及常见问题

    前面已经介绍了CAS服务器的搭建,详情见:搭建CAS单点登录服务器.然而前面只是简单地介绍了服务器的搭建,其验证方式是原始的配置文件的方式,这显然不能满足日常的需求.下面介绍下通过mysql数据库认证 ...

  9. 网页3D效果库Three.js初窥

    网页3D效果库Three.js初窥 背景 一直想研究下web页面的3D效果,最后选择了一个比较的成熟的框架Three.js下手 ThreeJs官网 ThreeJs-github; 接下来我会陆续翻译 ...

随机推荐

  1. Vim折叠模式设置

    参考文章:http://www.cnblogs.com/welkinwalker/archive/2011/05/30/2063587.html set foldmethod=indent " ...

  2. hdu 1009:FatMouse' Trade(贪心)

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  3. Type InvokeMember()用法简介

    举例: Type tDate = typeof(System.DateTime); Object result = tDate.InvokeMember("Now", Bindin ...

  4. [杂] ASP.NET MVC 之 Route To MvcHandler

    首先,本文参考了不少东东,仅供Q_L_H自己使用,ZZ自己负责.先上一张全家福: HttpModules and HttpHandlers ASP.NET MVC 是 HttpHandler. Url ...

  5. js选中当前菜单后高亮显示的导航条

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. python网页爬虫

    1. 静态页面爬取 这类最简单啦,右键->查看页面源码时,想下载的信息都能够显示在这里,这时只需要直接down页面源码,代码如下: # Simple open web import urllib ...

  7. Twitter search API

    Twitter crawler 与sina 微博类似,使用twitter api之前,首先要有twitter的账号,在twitter developer中创建应用(https://apps.twitt ...

  8. POJ3264Balanced Lineup 线段树练手

    题目意思:给定Q(1<=Q<=200000)个数A1,A2,```,AQ,多次求任一区间Ai-Aj中最大数和最小数的差 #include <iostream> #include ...

  9. env

    shell环境变量以及set,env,export的区别 原文链接 一.shell环境变量的分类以及set env export的区别: set:显示(设置)shell变量 包括的私有变量以及用户变量 ...

  10. WPF/Silverlight HierarchicalDataTemplate 模版的使用(转)

    上一篇 对Wpf/Silverlight Template 进行了总结,本篇继续上一篇,主要是介绍 HierarchicalDataTemplate 的使用方法.HierarchicalDataTem ...