我正在开发一个基于 QuickBlox 的 ChattAr-iOS 项目的应用程序,由于我无法与另一个应用程序通信,因此每次我尝试使用以下代码从我的应用程序中打开Waze应用程序时:UIWebViewController
- (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