【问题标题】:Include an iOS Storyboard project into another one?将 iOS Storyboard 项目包含到另一个项目中?
【发布时间】:2012-01-06 10:02:41
【问题描述】:

我和其他人在同一个项目中工作,但分开工作。想象第一个人创建了一个带有 UITableViewController 的 Storyboard 项目。第二个想要将前一个元素包含在他自己的 Storyboard 项目中。如何连接这两个 Storyboard 项目?

谢谢

【问题讨论】:

  • 您可以使用软件版本控制系统(也称为 svn)。否则你必须手动合并。
  • 我认为版本控制在这里没有帮助。故事板是在未记录的 XML 中,我不想尝试在 SVN 中合并它们……

标签: objective-c ios xcode storyboard


【解决方案1】:

我有一个解决方案:只需根据需要创建一个属性或变量。例如:

    @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"];
    ....
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-11
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-27
    相关资源
    最近更新 更多