使用xib教程并更改为故事板

时间:2012-07-26 23:05:02

标签: ios storyboard xib

我正在做以下教程(这只是一个例子): http://www.raywenderlich.com/1040/ipad-for-iphone-developers-101-uisplitview-tutorial

我通过创建一个名为MathMonsters的新项目来开始。 Xcode然后为iPad和iPhone创建文件(不能仅为iPad创建)。然后我继续为LeftViewController和RightViewController创建文件。然后,我通过选择视图并更改它们对应于上面创建的新类的类来更改MainStoryboard_iPad.storyboard中的相关属性。

然后我添加:

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController;
@property (nonatomic, retain) IBOutlet LeftViewController *leftViewController;
@property (nonatomic, retain) IBOutlet RightViewController *rightViewController;

在app委托文件中。现在它要求我控制拖动并连接插座。我尝试的很难,但我无法在故事板中的任何地方找到我可以将它们连接起来的地方。我尝试查看不同的文件,例如LeftViewController.h,RightViewController.h和MathMonstersAppDelegate.h。在最后一个文件中,我看到每个插座左侧都有空圈,但我无法连接它们。

我已经开始研究应用程序,只有在Xcode 4.2出来之后我才不熟悉xib教程,而且我很难看到较旧的教程并使它们适应新的方式编码。因此非常感谢帮助!如果它有助于发布代码的其他部分,请告诉我,我会这样做。

谢谢大家。

1 个答案:

答案 0 :(得分:0)

首先,您必须在项目中添加一个storrboard,然后为stordyboard ID分配和标识符。

以下是您可以通过.xib调用storyboard的示例。

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    YourViewController * yourView = (YourViewController *)[storyboard instantiateViewControllerWithIdentifier:@"identifier ID"];

希望它有所帮助。