[英]Communicating with other iOS application
我的工作是基於一個應用程序ChattAr-IOS從項目QuickBlox中,他們有一個UIWebViewController
由於我不能與其他應用進行溝通,每次我試圖打開Waze的使用下面的代碼應用形成我的應用程序:
- (void) navigateToLatitude:(double)latitude
longitude:(double)longitude
{
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"waze://"]]) {
//Waze is installed. Launch Waze and start navigation
NSString *urlStr = [NSString stringWithFormat:@"waze://?ll=%f,%f&navigate=yes", latitude, longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
} else {
//Waze is not installed. Launch AppStore to install Waze app
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/us/app/id323229106"]];
}
}
它導航到該UIWebView
。 該項目中有一個ChatARApplication
類,可能是導致問題的原因。
ChattARApplication.h
#import <UIKit/UIKit.h>
@interface ChattARApplication : UIApplication
@end
ChattARApplication.m
#import "ChattARApplication.h"
#import "WebViewController.h"
#import "AppDelegate.h"
@implementation ChattARApplication
-(BOOL)openURL:(NSURL *)url{
UITabBarController *tabBarControlelr = ((AppDelegate *)self.delegate).tabBarController;
if(tabBarControlelr.selectedIndex != 1){
return [super openURL:url];
}
// handle chat messages' links
WebViewController *webViewControleler = [[WebViewController alloc] init];
webViewControleler.urlAdress = [url absoluteString];
webViewControleler.webView.scalesPageToFit = YES;
UINavigationController *chatViewController = [tabBarControlelr.viewControllers objectAtIndex:1];
[chatViewController pushViewController:webViewControleler animated:YES];
[webViewControleler autorelease];
return NO;
}
@end
解決了問題
如此少的代碼和平就可以解決問題
if ([[url scheme] isEqualToString:@"waze"]) {
return [super openURL:url];
}
在-(BOOL)openURL:(NSURL *)url
主目錄
int main(int argc, char *argv[]){
@autoreleasepool {
return UIApplicationMain(argc, argv, NSStringFromClass([ChattARApplication class]), NSStringFromClass([AppDelegate class]));
}
}
我認為這是問題所在。如果要保留應用程序設置,可以在-(BOOL)openURL:(NSURL *)url;
放置一些代碼-(BOOL)openURL:(NSURL *)url;
希望能幫到你~~
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.