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.

最新文章

  1. DHTMLX 前端框架 建立你的一个应用程序教程(三)--添加一个菜单
  2. soapUI通过groovy脚本设置超时时间
  3. 《Visual Studio Magazine》2013年读者选择奖—界面框架类
  4. ios导航栏适配
  5. 微信支付WxpayAPI_php_v3(一)sdk简介与错误修改
  6. iOS监听模式系列之IOS中的几中观察监听模式
  7. LeetCode 242 Valid Anagram 解题报告
  8. LVS负载均衡群集
  9. Alpha 冲刺 (4/10)
  10. js缓存问题,修改js后代码不生效
  11. DELL MD3200i存储控制器解锁方法
  12. Linux 配置 hosts
  13. [Spring] 学习Spring Boot之一:基本使用及简析
  14. Xss漏洞原理分析及简单的讲解
  15. 【译】2017年要学习的三个CSS新特性
  16. pairs 和 ipairs区别
  17. 怎么查这个文件在linux下的哪个目录
  18. 路由搭建ovpn
  19. JavaScript中Array的正确使用方式
  20. 谷歌设置支持webgl

热门文章

  1. HTML5 Socket通信
  2. 表现层(jsp)、持久层(类似dao)、业务层(逻辑层、service层)、模型(javabean)、控制层(action)
  3. HDU 4343 贪心
  4. loj 1011(状态压缩+记忆化搜索)
  5. HBase伪分布式环境下,HBase的API操作,遇到的问题
  6. Xamarin Android项目运行失败
  7. NGUI创建Camera参数为Simple 2D的UI UI对象的结构UI Root(2D)
  8. Eval有什么功能?
  9. 简单几何(推公式) UVA 11646 Athletics Track
  10. 逆序数 POJ 2299 Ultra-QuickSort