Java程序如何导到iPhone运行_从另一个(iPhone)启动应用程序

在Swift 4.1和Xcode 9.4.1中

我有两个应用程序1)PageViewControllerExample和2)DelegateExample . 现在我想用PageViewControllerExample app打开DelegateExample应用程序 . 当我单击PageViewControllerExample中的打开按钮时,将打开DelegateExample应用程序 .

为此,我们需要对这两个应用程序的.plist文件进行一些更改 .

Step 1

在DelegateExample app中打开.plist文件并添加URL类型和URL方案 . 在这里,我们需要添加我们的必需名称,如“myapp” .

688f4451-e624-4016-b053-110b5daeeed1.png

Step 2

在PageViewControllerExample app中打开.plist文件并添加此代码

LSApplicationQueriesSchemes

myapp

现在,当我们点击PageViewControllerExample中的按钮时,我们可以打开DelegateExample应用程序 .

//In PageViewControllerExample create IBAction

@IBAction func openapp(_ sender: UIButton) {

let customURL = URL(string: "myapp://")

if UIApplication.shared.canOpenURL(customURL!) {

//let systemVersion = UIDevice.current.systemVersion//Get OS version

//if Double(systemVersion)! >= 10.0 {//10 or above versions

//print(systemVersion)

//UIApplication.shared.open(customURL!, options: [:], completionHandler: nil)

//} else {

//UIApplication.shared.openURL(customURL!)

//}

//OR

if #available(iOS 10.0, *) {

UIApplication.shared.open(customURL!, options: [:], completionHandler: nil)

} else {

UIApplication.shared.openURL(customURL!)

}

} else {

//Print alert here

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值