我和其他人在同一个项目中工作,但各自分开。想象一下,第一个人使用 UITableViewController 创建一个 Storyboard 项目。第二个想要将前一个元素包含在他自己的 Storyboard 项目中。如何连接这两个 Storyboard 项目?
谢谢
最佳答案
我有一个解决方案:只需根据需要创建一个属性或变量。例如:
@property (strong, nonatomic) UIStoryboard * storyboard1;
@property (strong, nonatomic) UIStoryboard * storyboard2;
.....
.m
-(void)initMyStoryboards{
storyboard1 = [UIStoryboard storyboardWithName:@"storyboard1" bundle:nil];
storyboard2 = [UIStoryboard storyboardWithName:@"storyboard2" bundle:nil];
}
-(void)launchViewFromS1{
//use view in storyboard1
MyViewController1 *myViewController = [self.storyboard1 instantiateViewControllerWithIdentifier:@"MainView"];
....
}
-(void)launchViewFromS2{
//use view in storyboard2
MyViewController2 *myViewController2 = [self.storyboard2 instantiateViewControllerWithIdentifier:@"OtherView"];
....
}
其他示例:
-(void)launchMyView{
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"storyboard1" bundle:nil];
ViewController1 *myViewController =[storyboard instantiateViewControllerWithIdentifier:@"MainView"];
....
}
关于objective-c - 将一个 iOS Storyboard 项目包含到另一个项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8756117/