我有两个用Objective C写的应用程序,我有一个iOS8越狱设备。我可以从另一个应用程序的视图中获取信息吗?
我可以访问其他应用程序的self.view吗?我想向其他应用程序中的按钮发送点击命令(touch up inside)?有可能吗?
我有,ios 8,越狱设备,xcode 6.3。我为我糟糕的英语感到抱歉。
发布于 2015-07-03 02:45:11
不需要越狱。
这是一些非常快速的东西,你可以尝试打开并点击第二个应用程序中的按钮。
使用URL方案从其他应用程序打开应用程序。
在plist中的第二个应用中,在URL类型\项目\URL Schemes\item0中添加字符串my2ndapp
要在使用第一个应用程序时打开第二个应用程序:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"my2ndapp://somedata"]];所以现在url: my2ndapp://somestring将打开你的第二个应用程序,并在它的appdelegate中运行方法:
(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
//do something with url if you need to, you can use it to tell yuor 2nd app do different things
openedFromURL=YES;//set bool flag, add this BOOL var in .h of appdelegate
return YES;
}然后在方法中的同一个appdelegate中
-(void)applicationDidBecomeActive:(UIApplication*)application{
if(!openedFromURL){return;}
//run method from viewcontroller you want, import it in .m and add it in .h of your appdelegate
MyViewController * myvc = [[MyViewController alloc]init];
[myvc myMethodHere];
openedFromURL=NO;//drop flag
}您可以转到特定的视图或视图控制器,并运行与您的按钮touch事件相关联的方法
同样,你也可以让第二个应用程序与第一个应用程序进行交互。
https://stackoverflow.com/questions/30606457
复制相似问题