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

查看:8
本文介绍了在本机代码中与 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. 会有什么缺点吗实现 UIWebView 而不是一个 UILabel 在我的情况下真的希望用户成为重定向回我的应用程序打完电话后?

推荐答案

  1. 使用 tel: URL 调用 -[UIApplication openURL:] 和单击 中指向相同 URL 的链接之间的行为确实不同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天全站免登陆