简体   繁体   English

Objective C访问另一个iOS应用

[英]Objective c access another ios app

I have two apps written with Objective C. I have an IOS 8 jailbroken device. 我有两个用Objective C编写的应用程序。我有一个IOS 8越狱设备。 Can I get information from the view of another application? 我可以从其他应用程序的角度获取信息吗?

Can I access self.view of the other app? 我可以访问其他应用程序的self.view吗? I want to send a clicks command (touch up inside) to button in my other applications? 我要向其他应用程序中的按钮发送点击命令(在内部进行润饰)吗? Is it possible? 可能吗?

I have, ios 8, jailbreak device, xcode 6.3. 我有iOS 8,越狱设备,xcode 6.3。 I'm sorry for my bad english. 对不起,我的英语不好。

no need for jailbrake. 无需越狱。

here is something really quick you can try to open and click button in 2nd app. 这是一个非常快速的操作,您可以尝试打开并单击第二个应用程序中的按钮。

Use URL schemes to open app from another app. 使用URL方案从另一个应用程序打开应用程序。

in the 2nd app in plist in URL types\\item\\URL Schemes\\item0 add string say my2ndapp 在URL类型\\ item \\ URL Schemes \\ item0的plist中的第二个应用程序中,添加字符串说my2ndapp

to open 2nd app from your 1st app use: 从您的第一个应用使用中打开第二个应用:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"my2ndapp://somedata"]];

so now url: my2ndapp://somestring - will open your 2nd app and run method in its appdelegate: 所以现在网址: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;
}

then in the same appdelegate in method 然后在方法的同一个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
}

you can go to your particular view or viewcontroller and run the method that is associated with your button touch up inside event 您可以转到特定的视图或视图控制器,并运行与事件内的按钮修饰相关联的方法

Similarly, you can make 2nd app interact with 1st one too. 同样,您也可以使第二个应用与第一个进行交互。

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

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