【Xamarin Doc】 Introduction to Storyboards 笔记
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
DismissViewControllermust 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 toUnwindToPinkViewController.
UIKit.UIStoryboard: Method Members
| static | FromName(string, Foundation.NSBundle) : UIStoryboard
|
|
InstantiateInitialViewController() : Foundation.NSObject
|
||
InstantiateViewController(string) : Foundation.NSObject
|
||
【Xamarin Doc】 Introduction to Storyboards 笔记的更多相关文章
- 机器学习介绍(introduction)-读书笔记-
一,什么是机器学习 第一个机器学习的定义来自于 Arthur Samuel.他定义机器学习为,在进行特定编程的情况下,给予计算机学习能力的领域.Samuel 的定义可以回溯到 50 年代,他编写了一个 ...
- OpenStack Network --- introduction部分 阅读笔记
Basic Networking 1.混杂模式(promiscuous mode):当网卡被配置为混杂模式时,它们会将所有的frame传递给操作系统,即使MAC地址不匹配. 2.交换机(switch) ...
- 人工智能头条(公开课笔记)+AI科技大本营——一拨微信公众号文章
不错的 Tutorial: 从零到一学习计算机视觉:朋友圈爆款背后的计算机视觉技术与应用 | 公开课笔记 分享人 | 叶聪(腾讯云 AI 和大数据中心高级研发工程师) 整 理 | Leo 出 ...
- 第一周课堂笔记2th
上课笔记2th https://mubu.com/doc/2gxvIvVLG0(老师笔记网址) 1. python python运行过程 把源代码转化成字节码(机器不能识别) 也可能不产生py ...
- MongoDB学习之--增删改查(1)
本文是对mongodb学习的一点笔记,主要介绍最简单的增删改操作,初学,看着API,有什么错误,希望大家指正:(使用官方驱动) 1.增 增加操作是最简单的,构造bsonDcument插入即可: 方式1 ...
- python merry -- error handling in the real world
参考: https://www.youtube.com/watch?v=8kTlzR4HhWo https://github.com/miguelgrinberg/merry 背景 本文实际就是把 d ...
- CUnit的用法
转自:http://blog.csdn.net/scucj/article/details/4385630/ CUnit下载地址: http://sourceforge.net/projects/cu ...
- CAS单点登录之mysql数据库用户验证及常见问题
前面已经介绍了CAS服务器的搭建,详情见:搭建CAS单点登录服务器.然而前面只是简单地介绍了服务器的搭建,其验证方式是原始的配置文件的方式,这显然不能满足日常的需求.下面介绍下通过mysql数据库认证 ...
- 网页3D效果库Three.js初窥
网页3D效果库Three.js初窥 背景 一直想研究下web页面的3D效果,最后选择了一个比较的成熟的框架Three.js下手 ThreeJs官网 ThreeJs-github; 接下来我会陆续翻译 ...
随机推荐
- Maven使用笔记(七)Maven使用问题记录
1.Java-maven异常-cannot be cast to javax.servlet.Filter 报错 tomcat 启动后先将tomcat/lib目录下的jar包全部读入内存,如果weba ...
- hdu 1556 树状数组+点查询
树状数组 N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一 ...
- RTP与RTCP协议介绍
转自:http://zhangjunhd.blog.51cto.com/113473/25481/ 本文主要介绍RTP与RTCP协议. author: ZJ 06-11-17 Blog: [url ...
- Lua Require函数
转自:http://www.cppblog.com/cslover/archive/2013/12/21/204934.html Lua提供高级的require函数来加载运行库.粗略的说require ...
- UVA - 10891 Game of Sum 区间DP
题目连接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19461 Game of sum Description This ...
- CC2540开发板学习笔记(四)——定时器
一.实验内容 分别使用定时器T1和T3使得LED周期性闪烁 二.实验过程 1.定时器T1(查询IRCON来控制) (1)需要调配的寄存器 T1CTL(0XE4) Timer1控制寄存器 BIT3, ...
- sqldatasource控件设置where语句
按照学号查找显示信息,我现在也不知道各部分代表的含义,先记下来
- SU suplane命令学习
各位博友,不足之处,批评指正! 用其他软件打开看看, 注意:下图中应该是倾角,dip=Δt/Δx,单位为ms/traces,
- 模拟 ZOJ 3736 Pocket Cube
题目传送门 题意:魔方最多旋转n次,问最多能使多少面颜色相同 分析:6种状态(3种旋转方式*顺逆方向,其他对称的!),首先先打个表,然后很愉快的DFS.自己写的时候费劲脑汁,代码很长,还TLE了... ...
- 重拾ZOJ 一周解题
ZOJ 2734 Exchange Cards 题目大意: 给定一个值N,以及一堆卡片,每种卡片有一个值value和数量number.求使用任意张卡片组成N的方式. 例如N = 10 ,cards(1 ...