xib →→→→→页面切换

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
//  代理
_table.dataSource =self;
_table.delegate =self;
}
//行
- ( NSInteger ) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
//复用
- ( UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *TableI = [tableView dequeueReusableCellWithIdentifier:@"hello"];
//  判断tablei的值
if (TableI==nil) {
TableI = [[ UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"hello"];
//  设置文本
}
TableI.textLabel.text = @"world";
return TableI;
}

//点击链接进入另一页面
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self performSegueWithIdentifier:@"xian" sender:nil];
}
//回调
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"xian"]) {
id send = segue.destinationViewController;
[send setValue:@"welcome" forKey:@"string"];
}

}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

@end
//协议
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *table;
@end


你可能感兴趣的:(xib →→→→→页面切换)