我有一个现成的项目(使用应用程序委托创建和启动,但没有 xib、nib)。现在我想从另一个项目调用并启动它。但是我不能使用 initwithnib,如何从另一个项目中包含并启动这个现成的项目?更具体地说,如何将只有自己的 appDelegate 和 Mainwindow.xib 文件的 Apple 示例代码“TableViewUpdates (TVAnimationsGestures.xcodeproject)”添加和集成到我自己的应用程序中?谢谢!或者您可以将 xib 文件添加到 Apple 的示例代码“TableViewUpdates (TVAnimationsGestures.xcodeproject)”中,以便我可以在我的另一个项目中使用 initWithNib 来调用和运行示例代码。谢谢 !
问问题
186 次
1 回答
2
我在 Xcode 4.3.2 上工作。
- 创建单视图单视图应用程序。
- 展开 MoviePlayer 示例中的所有文件夹。选择除 info.plist、main、Frameworks、Products 文件夹、readme.txt、MoviePlayer.project 之外的所有文件。将它们复制到新的空项目中。不要忘记检查“添加到目标”。
- 在目标的构建阶段选项卡中添加了 MediaPlayer.framework(在链接二进制与库中)
- 将 MainWindow.xib 中的所有对象复制到您自己的 viewController 的 xib。
比在 ViewController.h 中:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITabBarController *tabBarConroller;
@end
将您的 tabBarController 从 ViewController.xib 连接到属性。
比在 ViewController.m 中:
@implementation ViewController
@synthesize tabBarConroller;
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:tabBarConroller.view];
}
- (void)viewDidUnload
{
[self setTabBarConroller:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
...other appdelegateMethods ...
@end
7. 检查 viewController.xib 中的所有对象是否都有必要的出口。
6. 编辑 > 重构 > 转换为 ARC。(接下来,好的……)
完成。
于 2012-05-27T15:19:15.927 回答