Xcode StoryBoard 基础事件和跳转处理

下面是页面进行跳转的方法

页面上跳转 一般有两种   一种是 用view 当事件源。 比如上图 按住control 点击button 直接拉到 下个界面

 当点击 button  就直接跳转 连接的界面。

还有种 是controller 连接 controller 。  就是 两个界面直接拉   然后设置 中间线 segue 的identifier 按自己喜好输

然后 在你要跳转的代码段中 加

[selfperformSegueWithIdentifier:@"gotoOther"sender:self];


下面新建个UIViewController

 

这是 .h 文件

#import<UIKit/UIKit.h>


@interface firstController :UIViewController


@end

回到storyboard  点击第一个界面  设置它的 class 为刚建的firstController

接着点击然后界面变成

你可以看到与当前界面绑定的controller 代码

直接按住control 从 button 拉到代码中  系统会自动弹出选择筐  你可以选它为 outlet 或者是 事件

 

那你就可以写代码拉    还可以把多个事件 绑定到同一个方法中 

- (IBAction)bt_pressed:(id)sender {

    

    if([bt_go isEqual:sender])

    {

        [selfperformSegueWithIdentifier:@"gotoOther"sender:self];

    }

    if([bt_cancel isEqual:sender])

    {

        exit(0);

    }

}

可以直接选择事件进行绑定

有时候 你会发现代码不对    可以通过automatic 选择正确的文件

最后是一些跳转和返回的方法

 

 //根据 segue Identifier跳转界面

    [self performSegueWithIdentifier:@"GotoTwo" sender:self];

    

   //以modal 方式跳转

    [self presentModalViewController:nil animated:YES];

    

   //压进一个viewcontroller

    [self.navigationController pushViewController:nil animated:YES];


   //弹出一个viewcontroller  相当与返回上一个界面

    [self.navigationController popViewControllerAnimated:YES];

    

   // 以 modal跳转的返回方法

    [self dismissModalViewControllerAnimated:YES];

 

转载:http://blog.csdn.net/li6185377/article/details/7456458

 

 

 

posted @ 2014-03-05 13:28  无名盗闪  阅读(1017)  评论(0)    收藏  举报