与其他iOS应用程序通信

时间:2013-01-25 04:36:01

标签: iphone ios uiwebview quickblox

我正在开发一个基于来自ChattAr-iOSQuickBlox项目的应用,其中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"]]; } } 每次尝试使用以下代码打开我的应用程序中的Waze应用程序:

UIWebView

导航到ChatARApplication。该项目中有一个类#import <UIKit/UIKit.h> @interface ChattARApplication : UIApplication @end 可能导致问题。

ChattARApplication.h

#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

ChattARApplication.m

{{1}}

2 个答案:

答案 0 :(得分:1)

解决了问题

这一点代码的和平做了伎俩

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

-(BOOL)openURL:(NSURL *)url

答案 1 :(得分:0)

的main.m

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

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

中添加一些代码

希望它可以帮到你~~