二,storyboard出现的比较晚,封装的教程如今全网仅此一家,方便开发!
首先创建静态库,方法都和以前的一样,就把xib换成storyBoard就行了,难就难在怎么引用上,下面介绍于下:
在跟控制器上声明一个属性一个方法,为了调用的时候更方便
//比如A控制器要跳转过来,就把A的实例赋值给此source属性然后调用 startViewController方法就可以跳转过来
@property (nonatomic,strong)UIViewController *sourceViewController;
//启动该视图控制器,显示天气视图,为sourceViewController赋值之后就调用该方法
-(void)startViewController;
然后实现方式如下:
-(void)startViewController
{
NSBundle*bundle=[NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"WeatherDataLibResources" withExtension:@"bundle"]];
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"WeatherStoryboard" bundle:bundle];
[self.sourceViewController presentViewController:[storyboard instantiateInitialViewController] animated:YEScompletion:^{
}];
}
三,在引用的地方先引入头文件,然后实例化,设置参数,方式如下:
WeatherViewController *weatherViewController=[[WeatherViewController alloc]init];
weatherViewController.sourceViewController=self;
[weatherViewController startViewController];
转载自:http://www.cnblogs.com/huntaiji/p/3490911.html