与UIWebView相比,本机代码中的电话呼叫不同后返回应用行为 [英] Return to app behavior after phone call different in native code than UIWebView

查看:110
本文介绍了与UIWebView相比,本机代码中的电话呼叫不同后返回应用行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Apple的文档,按顺序要通过我的应用拨打电话,我需要实施以下协议:

According to Apple's documentation, in order to make phone call from my app, I need to implement the following protocols:

HTML链接:

<a href="tel:1-408-555-5555">1-408-555-5555</a>

原生应用程序URL字符串:

tel:1-408-555-5555

然而,在完成从UIWebView内的HTML链接发起的电话呼叫后,我被重定向到我的应用程序。但是在完成从本机应用程序URL字符串拨打的电话后,我的iphone会保留在iphone的常规电话应用程序中,如果我想返回我的应用程序,我必须手动执行此操作。

However, upon completion of a phone call initiated from an HTML link inside a UIWebView, I am redirected right back to my application. But upon completion of a phone call made from a native application URL string, my iphone stays in the iphone's regular phone application, and if I want to return to my application I have to do so manually.

据我所知,通过阅读其他人的说法,没有办法改变这种行为。

As far as I can tell from reading what others have said, there is no way to change this behavior.

这是我的问题:



  1. 制作手机后返回应用程序是不可能的
    从本机
    应用程序URL字符串调用?

  2. 在$ $ b $的情况下实现UIWebView而不是
    a UILabel的
    是否有任何缺点? b真的希望用户在拨打完电话后将
    重定向回我的应用程序


推荐答案


  1. 使用 - [UIApplication openURL:] 之间的行为确实有所不同> tel: URL,然后单击指向同一UR的链接L在 UIWebView

  1. Behavior does differ between calling -[UIApplication openURL:] with a tel: URL, and clicking a link to the same URL in a UIWebView.

使用 UIWebView 而不是UILabel可能有一些缺点,但您不必实际显示 UIWebView 来获取其 tel URL处理行为。相反,只需在UIWebView实例中加载 tel URL请求,而不将其添加到视图层次结构中。

Using a UIWebView instead of a UILabel might have some downsides, but you don't have to actually display the UIWebView to get its tel URL handling behavior. Instead, just load a tel URL request in an instance of UIWebView without adding it to your view hierarchy.

例如:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface PhoneCaller : NSObject
{
  @private
    UIWebView *webview;
}
- (void)callTelURL:(NSURL *)url;
@end

@implementation
- (id)init
{
    self = [super init];
    if (self)
    {
        webview = [[UIWebView alloc] init];
    }
    return self;
}
- (void)callTelURL:(NSURL *)url
{
    [webview loadRequest:[NSURLRequest requestWithURL:url]];
}
- (void)dealloc
{
    [webview release];
    [super dealloc];
}
@end

这篇关于与UIWebView相比,本机代码中的电话呼叫不同后返回应用行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆