可视化编程之storyboard

#import "RootViewController.h"
#import "SecondViewController.h"
@interface RootViewController ()

- (IBAction)refist:(id)sender;
@property (strong, nonatomic) IBOutlet UITextField *usernameTF;

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#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.
}
*/


//当storyboard中的视图控制器,通过segue完成页面跳转时,此方法就会执行
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    //segue有三个非常重要的属性
    /**
     * 1、identifier,标识符(segue),可以选择性地跳转
     * 2、sourceViewController,源视图控制器
     * 3、destinationViewController,目标视图控制器
     
     */
    
    if ([segue.identifier isEqualToString:@"secondVC"]) {
        SecondViewController *secondVC = segue.destinationViewController;
        secondVC.string = self.usernameTF.text;
        RootViewController *v1 = segue.sourceViewController;
        [UIView transitionFromView:v1.view toView:secondVC.view duration:8.0 options:UIViewAnimationOptionTransitionCurlDown completion:^(BOOL finished) {
            
        }];
        
    }
    
}
- (IBAction)refist:(id)sender {
    //每一个视图控制器都有一个属性叫stroyboard,可以找到当前视图控制交由哪个故事板管理。并且故事板可以通过stroyboardID找到加到其内部的视图控制器
//    UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"second"];
//    [self presentViewController:controller animated:YES completion:nil];
    [self performSegueWithIdentifier:@"secondVC" sender:nil];
    
}
@end
#import "SecondViewController.h"

@interface SecondViewController ()

@property (strong, nonatomic) IBOutlet UILabel *showLabel;
//@property (nonatomic,copy) NSString *string;


@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.showLabel.text = self.string;
    // Do any additional setup after loading the view.
}
#import "MyTableViewController.h"
#import "MyTableViewCell.h"
@interface MyTableViewController ()

@end

@implementation MyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 10;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *ID = @"reuse";
    
    MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID forIndexPath:indexPath];
    
    if (cell == nil) {
        cell = [[MyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        
    }
//    cell.label1.text = [NSString stringWithFormat:@"仙%ld",indexPath.section + 10];
//    cell.label2.text = [NSString stringWithFormat:@"魔%ld",indexPath.row + 10];

    cell.label1.text = @"仙逆";
    cell.label2.text = [NSString stringWithFormat:@"求魔"];
    
    // Configure the cell...
    
    return cell;
}



转载于:https://www.cnblogs.com/networkprivaate/p/5204416.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值