how to add a ready-to-use project ( created and started with application delegate but without xib,nib) to another project

此生再无相见时 提交于 2020-01-05 08:49:50

问题


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.

  1. Create sigle view sigle view app.
  2. 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".
  3. In target's build phase tab added MediaPlayer.framework (in link Binary with libs)
  4. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!