简体   繁体   English

将iOS4项目集成到iOS5项目中

[英]integrating iOS4 project into iOS5 project

I have a newbie question about integrating two iOS apps. 我有一个关于整合两个iOS应用的新手问题。 I have created an app in iOS 5 (my first app so I dont have any knowledge of iOS 4 except the fact thah there were xibs files instead of storyboard and also ARC was not included). 我已经在iOS 5中创建了一个应用程序(我的第一个应用程序,因此我除了对iOS 4有任何了解之外,除了有xibs文件而不是Storyboard,还没有ARC)。 Now I have to include one older standalone app (built for iOS 4 with xibs and non ARC) to my iOS 5 app. 现在,我必须在iOS 5应用程序中包含一个较旧的独立应用程序(针对带有xibs和非ARC的iOS 4构建)。 Lets say that in my app on Main menu view there will be a new button opening the main menu of the other app. 可以说,在我的主菜单视图中的应用程序中,将有一个新按钮打开另一个应用程序的主菜单。

So I did some research and find out how to disable ARC by the fno-objc-arc flag. 因此,我进行了一些研究,以了解如何通过fno-objc-arc标志禁用ARC。 Fine, now I have imported all the files of the second app to mine app and all the classes have the flag set. 很好,现在我已将第二个应用程序的所有文件导入到我的应用程序中,并且所有类都设置了标志。 I can still run my app without problem. 我仍然可以毫无问题地运行我的应用程序。

Now I have no idea how to let my new button to open the mainViewController of the old app - this app has MainWindow.xib (contains a window and one navigation controller). 现在我不知道如何让我的新按钮打开旧应用程序的mainViewController-此应用程序具有MainWindow.xib(包含一个窗口和一个导航控制器)。 This MainWindow is set to be Main Interface in the old project. 在旧项目中,此MainWindow设置为Main Interface。 There are also some init call in appMainDelegate file. appMainDelegate文件中也有一些初始化调用。 Where can I call them in my app? 在我的应用程序中我可以在哪里称呼他们?

Could anybody tell me what needs to be done. 谁能告诉我需要做什么。 I have an idea, that I will add only one new UIViewController to my storyboard. 我有一个主意,我只会在故事板上添加一个新的UIViewController。 This will be the starting point for the old app and than everything will work as it used to. 这将是旧应用程序的起点,并且所有内容都将像往常一样工作。 Or will I have to create more controllers (for every xib) in my storyboard? 还是我必须在情节提要中为每个xib创建更多的控制器? This is where I dont know what to do. 这是我不知道该怎么办的地方。 Any help much appriciated. 任何帮助大有作为。 thank you 谢谢

Try doing something like the following, anything like it or simmular should work: 尝试执行以下操作,类似或类似的操作都可以:

In the method of the button (the one you call your new button) have it execute the following code: 在按钮的方法(您称为新按钮的按钮)中,执行以下代码:

OldAppMainViewController *controller = [[OldAppMainViewController alloc] init];
//Here you can assign vallues to any properties that you might want to
[self.navigationController pushViewController:controller animated:YES];

That old apps main view controller should have a init with nub named function so it should work. 那个旧的应用程序主视图控制器应该具有一个带有nub命名函数的init,因此它应该可以工作。 If this does not work try something along the lines of: 如果这样做不起作用,请尝试以下方法:

OldAppMainViewController *controller = [[OldAppMainViewController alloc] initWithNibName:@"OldAppMainViewController" bundle:nil];

Where the NIB name is the .xib file name without the extension. NIB名称是不带扩展名的.xib文件名。

Also make sure that all connections in interface builder is setup correctly 还要确保正确设置了接口构建器中的所有连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM