问题
I have a ready-to-use project ( created and started with application delegate but without xib,nib). Now I want to invoke and start it from another project. But I can't use initwithnib, how can I include and start this ready-to-use project from another project? More specifically, how to add and integrate Apple's Sample code " TableViewUpdates ( TVAnimationsGestures.xcodeproject ) " which only has its own appDelegate and Mainwindow.xib file to my own application? thanks! Or can you add a xib file to the Apple's Sample code " TableViewUpdates ( TVAnimationsGestures.xcodeproject ) " so that I may use initWithNib in my another project to invoke and run the sample code. thanks !
回答1:
I work on Xcode 4.3.2.
- Create sigle view sigle view app.
- Expand all folders in MoviePlayer example. Select all files, except info.plist, main, Frameworks, Products folders, readme.txt, MoviePlayer.project. Copy them to new empty project. Don't forget to check "add to target".
- In target's build phase tab added MediaPlayer.framework (in link Binary with libs)
- Copy all object from MainWindow.xib to your own xib for your viewController.
Than in ViewController.h :
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITabBarController *tabBarConroller;
@end
Connect your tabBarController from ViewController.xib to the property.
Than in 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. Check that all objects in viewController.xib has necessary outlets.
6. Edit > Refactor > Convert to ARC. (next, ok...)
It's done.
来源:https://stackoverflow.com/questions/10600979/how-to-add-a-ready-to-use-project-created-and-started-with-application-delegat