实例化是指把拖拽界面代码化,Storyboard和Xib实例化差不多。
1、Storyboard实例化
UIStoryboard *storyboard = [UIStoryboardstoryboardWithName:@"MainStoryboardstoryboard(storyboard文件的名字)"bundle:nil];
//实例化
UIViewController *viewcontroller=[storyboardinstantiateViewControllerWithIdentifier:@"ThreadViewController(storyboard的id)"];
1、Xib实例化
(1) UIViewController *viewcontroller=[[UIViewController alloc] initWithNibName:@”xib文件名字“ bundle:nil];
(2)NSArray *viewary=[[NSBundle mainBundle]loadNibNamed:@"xib文件名字" owner:self options:nil];
UIViewController *viewcontroller=[viewary lastObject];
xib自定义cell
static NSString CustomCellIdentifier=@"threadfrumCell";
UINib *nib = [UINibnibWithNibName:@"CustomCell"bundle:nil];
UITableViewCell *[tableView registerNib:nibforCellReuseIdentifier:CustomCellIdentifier];
CustomCell文件继承UITableViewCell