#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