monotouch iphone 使用storyboard布局界面,界面代码跳转

monotouch 中分为Iphone 和Ipad。

Iphone 中 的UIViewController 的构造函数带有参数 (IntPtr handle) : base (handle);

Ipad 中的UIViewController的构造函数不带有参数。

所以Ipad 再使用Storyboard以后可以很容易的进行跳转。代码如下:

ifthis.NavigationController!=null)
{
  this.NavigationController.PushViewController(new AA(),true);
}

但是Iphone如果像Ipad一样跳转就需要传入handle参数,这个参数我并不知道该如何获取。

除去PushViewController的跳转方式,我想到了使用storyboard中的Segue,但是经过查询,可以手动制作Segue。

具体步骤如下:

1.先选中Storyboard中的Controller,设置Identifier。

2.跳转方法

    public static void NavategiteToSettings (UINavigationController controller)
        {
            if(controller==null)return;
            UIStoryboard board=UIStoryboard.FromName("MainStoryboard",null);
            UIViewController setting=(UIViewController)board.InstantiateViewController("Settings");
            controller.PushViewController(setting,true);
        }

注意使用此跳转方法时需要调度UI线程。

 

 

posted @ 2013-03-20 12:01  静艳  阅读(454)  评论(0编辑  收藏  举报