写在前面的话
近期接到这样一个需求,需要为app内机构详情页提供2种不同的布局,效果图如下,

机构详情页的2种布局.png
拿到该需求后,你都有哪些思路?
1、创建2个
UIViewController, 界面xib实现,逻辑代码贴贴贴。2、创建1个
UIViewController,纯代码实现。3、创建1个
UIViewController, 不同场景加载不同的storyboard或者xib实现。我们采取第三种方法实现,那就引出了今天的问题,iOS控制器
ViewControlle加载都有几种方式?
代码实现
通过alloc或者new方法实现。
故事板加载
在Main.storyboard实现如下截图

故事板加载控制器.png
代码实现部分
#import "AHTestViewController.h"
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
AHTestViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"AHDemo2"];
在跳转到机构详情页时只需按照不同场景加载不同故事板即可.
if (item.organ_style.integerValue==1){
OrganOtherDetailViewController *VC = [[OrganOtherDetailViewController alloc]initWithType:detailone];
VC.item =self.orgaDataArr[indexPath.section];
[self.navigationController pushViewController:VC animated:YES];
}else if (item.organ_style.integerValue==2){
OrganOtherDetailViewController *VC = [[OrganOtherDetailViewController alloc]initWithType:detailtwo];
VC.item =self.orgaDataArr[indexPath.section];
[self.navigationController pushViewController:VC animated:YES];
}
xib实现
新建一xib文件,在xib文件中做如下设置

xib加载控制器.png
代码实现部分
#import "AHTestViewController.h"
AHTestViewController *vc = [[AHTestViewController alloc]initWithNibName:@"AHTest" bundle:nil];