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. Codeigniter:如何写一个好的Model

    本文是关于在Code Igniter PHP MVC框架中如何编写Model方法. CRUD 方法 CRUD 是Create, Retrieve, Update, and Delete的缩写. 这些是 ...

  2. sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)

    Crack Mathmen Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  Since mathmen take securit ...

  3. hdu 1010:Tempter of the Bone(DFS + 奇偶剪枝)

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  4. 在HTML中优雅的生成PDF

    关键代码<script type=</text>          </para>          <para align=" value=" ...

  5. Tomcat安装及配置

    用来进行web开发的工具有很多,Tomcat是其中一个开源的且免费的java Web服务器,是Apache软件基金会的项目.电脑上安装配置Tomcat的方法和java有些相同,不过首先需要配置好jav ...

  6. HTML-Canvas02

    文字对齐方式 : 水平对齐 //是用 textAlign 属性设置水平对齐方式(默认坐标点) ctx.textAlign = "start"; ctx.font = "3 ...

  7. 使用NGUINGUI的相关介绍

    1.3  使用NGUI 要使用NGUI,需要首先为游戏项目导入NGUI插件资源,然后再创建UI Root对象,在这以后才可以添加各种UI控件,下面本节会详解介绍这些知识本文选自NGUI从入门到实战! ...

  8. android 蓝牙设备监听广播

    蓝牙权限 <uses-permission android:name="android.permission.BLUETOOTH" /> 1.监听手机本身蓝牙状态的广播 ...

  9. ognl el表达式 property

    <s:iterator value="list" status="statu" var="alarminfo"> <tr& ...

  10. Windows Phone7 快递查询

        (1)API去友商100里申请 布局代码: Exp.xaml <phone:PhoneApplicationPage x:Class="WindowsPhone_Express ...