【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 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.

时间: 2024-07-29 12:29:47

【Xamarin Doc】 Introduction to Storyboards 笔记的相关文章

Differences Between Xcode Project Templates for iOS Apps

Differences Between Xcode Project Templates for iOS Apps When you create a new iOS app project in Xcode, you get to choose between several project templates, from the aptly named “Empty Application” to specialized things like an “OpenGL Game”. I noti

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

网页3D效果库Three.js初窥 背景 一直想研究下web页面的3D效果,最后选择了一个比较的成熟的框架Three.js下手 ThreeJs官网 ThreeJs-github; 接下来我会陆续翻译 Three.js官网的文档,部分文字和代码为我个人添加. 第一部分:three.js介绍 创建场景 这部分的目标是为Three.js做一个简单的介绍,我们会以创建一个场景,一个旋转的立方里开始,文章的结尾会有一个可运行的完整示例为你解惑. 开始之前 在你使用Three.js之前,你需要在你的电脑上建

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

前面已经介绍了CAS服务器的搭建,详情见:搭建CAS单点登录服务器.然而前面只是简单地介绍了服务器的搭建,其验证方式是原始的配置文件的方式,这显然不能满足日常的需求.下面介绍下通过mysql数据库认证的方式. 一.CAS认证之mysql数据库认证 1.在mysql中新建一个cas数据库并创建user表 CREATE DATABASE /*!32312 IF NOT EXISTS*/`cas` /*!40100 DEFAULT CHARACTER SET gbk */; USE `cas`; /*

OpenCV3.0 3.1版本号的改进

?? 摘要 OpenCV如今更新到了3.1版本号,相对OpenCV2有了非常大改进,当中对于硬件加速,移动开发(IOS,android)的支持成为亮点. 新版的OpenCV採用了内核+插件的架构模式,总体上更加易于扩展. 当中最与时俱进的特点就是 支持最新的 Windows 和 OS X 操作系统和最新的开发工具 (VS2015 和 Xcode 7),支持 Andorid 5.软件的更新换代推动硬件更新,并进一步推动摩尔定律,相信OpenCV的新版会带动很多其它人更新Win10,vs2015等等

opencv拼接相关1

这里面都是一些比较杂的东西,没什么实际意义.主要是为了,后面能跑一个程序: Stitcher: 抠细节: http://docs.opencv.org/2.4.2/modules/stitching/doc/high_level.html?highlight=stitcher#stitcher Stitcher是啥? class Stitcher High level image stitcher. It’s possible to use this class without being aw

程序员开发书籍汇总

文件类型 文件名称 更新时间 pdf 浅谈ACEGI配制 .pdf 2015/10/9 pdf AJAX In Action.pdf 2015/10/9 pdf Ajax.pdf 2015/10/9 txt AjaxHttpRequest.txt 2015/10/9 pdf AJAXInAction.pdf 2015/10/9 pdf Ajax经典案例开发大全.pdf 2015/10/9 pdf AJAX开发简略(含续一).pdf 2015/10/9 pdf AJAX开发简略.pdf 2015/

JProfiler 简要使用说明

1.简介 JProfiler是一个ALL-IN-ONE的JAVA剖析工具,可以方便地监控Java程序的CPU.内存使用状况,能够检查垃圾回收.分析性能瓶颈. 本说明文档基于JProfiler 9.2编写. 2.安装 安装包:JProfiler_windows-x64_9_2.exe (JProfiler 9注册码.txt) 如果要监控的远端服务器操作系统不同,在Select Component这步,可以选择安装不同系统的Native libraries for profiling agent.

Maven Pom的一些知识

大部分整(fan)理(yi)自Maven官方网站的DOC Introduction to POM https://maven.apache.org/guides/introduction/introduction-to-the-pom.html POM( Project Obeject Model )是一个Maven工程中最基本的组件单元, 1. 项目变量/POM中的变量: 所有只有单一值的元素都可以作为变量来使用. ${project.build.sourceDirectory}, ${pro

EntityFramework Core 学习扫盲

0. 写在前面 1. 建立运行环境 2. 添加实体和映射数据库 1. 准备工作 2. Data Annotations 3. Fluent Api 3. 包含和排除实体类型 1. Data Annotations [NotMapped] 排除实体和属性 2. Fluent API [Ignore] 排除实体和属性 4. 列名称和类型映射 1. Data Annotations 5. 主键 1. Data Annotations [Key] 2. Fluent API [HasKey] 6. 备用