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. tomcat The file is absent or does not have execute permission

    [root@centos02 bin]# ./startup.sh Cannot find ./catalina.sh The file is absent or does not have exec ...

  2. ytu 1304:串的简单处理(水题)

    串的简单处理 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 39  Solved: 11[Submit][Status][Web Board] Desc ...

  3. jquery 展开折叠效果

    仅供参考  图片 jquery.js 自己处理 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"& ...

  4. Android ActionBar 一步一步分析 (转)

    原文摘自:http://blog.csdn.net/android2me/article/details/8874846 1.Action Bar 介绍 我们能在应用中看见的actionbar一般就是 ...

  5. MSSQL 2005 列转行应用案例

    /*MSSQL 2005 列转行应用案例 By claro(陈亮) 2008-12-2 转载请包含此信息*/ --test table KuCunMX If object_id ('KuCunMX') ...

  6. Xamarin Android布局文件没有智能提示

    Xamarin Android布局文件没有智能提示 在Visual Studio 2015中,Android项目的Main.axml文件没有智能提示,不便于布局文件的编写.解决办法:(1)从Xamar ...

  7. Hadoop_10_shuffle02_详解Shuffle过程【来源网络】推荐更为详细

    网址:http://www.cnblogs.com/felixzh/p/4680808.html Shuffle过程,也称Copy阶段.reduce task从各个map task上远程拷贝一片数据, ...

  8. POJ2699 The Maximum Number of Strong Kings(最大流)

    枚举所有Strong King的状态(最多1024种左右),然后判断是否合法. 判定合法用网络流,源点-比赛-人-汇点,这样连边. 源点向每场比赛连容量为1的边: 如果一场比赛,A和B,A是Stron ...

  9. Android view 的事件分发机制

    1 事件的传递顺序是 Activity -> Window -> 顶层View touch 事件产生后,最先由 activity 的 dispatchTouchEvent 处理 /** * ...

  10. 【wikioi】1285 宠物收养所

    题目链接:http://www.wikioi.com/problem/1285/ 算法:Splay 刚开始看到这题,就注意到特征abs了,并且数据n<=80000显然不能暴力,只能用nlgn的做 ...