0

我正在开发一个基于 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
4

2 回答 2

1

解决了问题

这个小小的代码和平做到了

 if ([[url scheme] isEqualToString:@"waze"]) {
    return [super openURL:url];
}

-(BOOL)openURL:(NSURL *)url

于 2013-01-29T11:15:42.970 回答
0

主文件

int main(int argc, char *argv[]){
    @autoreleasepool {
        return UIApplicationMain(argc, argv, NSStringFromClass([ChattARApplication class]), NSStringFromClass([AppDelegate class]));
    }
}

我认为是问题所在。如果您想保留应用程序设置,您可以在-(BOOL)openURL:(NSURL *)url;

希望对你有帮助~~

于 2013-01-25T07:07:21.140 回答