iOS开发学习之路【UI界面】——storyboard

storyboard 简介

​ 中文名:故事版、串联图

​ storyboard 中间的一个屏幕称为一个 scene (场景),了;两个屏幕之间的转换称为 segue (过渡)。

新建一个storyboard

  1. command+N 新建 storyboard ;

  2. 添加两个 View controller ;

  3. 使用 Button 连接连个场景 ;

  4. 设置哪一幕是入口点 ;
    在这里插入图片描述

  5. 在 Info.plist 配置 Main storyboard file base name 就是刚刚常见的 storyboard 文件名 ;
    在这里插入图片描述

  6. 创建 class 与每一个 View Controller 相关联 ;

在这里插入图片描述在这里插入图片描述
7. 愉快的运行成功。。。

传递数据

  1. FirstViewController.m
#import "SecondViewController.h"

#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    
    SecondViewController *second = segue.destinationViewController;
    
    second.data = @"张飞来也。。。";
}
  1. SecondViewController.h

    @property(nonatomic,copy)NSString *data;
    
  2. SecondViewController.m

     NSLog(@"data=%@", self.data);
    
  3. 成功。。。
    在这里插入图片描述

添加 Tab Bar Controller

  1. 选中要添加的 View Controller
    在这里插入图片描述

  2. 成功
    在这里插入图片描述

storyboard 和代码混合导航

#import "OneViewController.h"
#import "TwoViewController.h"

@interface OneViewController ()

@end

@implementation OneViewController
- (IBAction)go:(id)sender {
    TwoViewController *t = [self.storyboard instantiateViewControllerWithIdentifier:@"second_id"];
    [self presentViewController:t animated:YES completion:^{
        
    }];
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/guyindong/article/details/88751512
今日推荐