现有程序无法在iOS5上运行

发布于 2024-12-11 06:59:44 字数 1545 浏览 0 评论 0原文

我的两个程序在 AppStore 上已经有几个月了,在 iOS3 和 iOS4 上运行没有任何问题,但与 iOS5 不兼容。

在我看来,苹果改变了一些事情,让开发者的生活变得更加困难。

问题之一是:

- (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType {
    // Only do something if a link has been clicked
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        NSString *link = [[request URL] absoluteString];
        if ([link hasPrefix:@"playSound:"]) {
            [PlayAudio playAudio: [link substringFromIndex:10]];
            return NO;
        }
    }
    return YES;
}

造成问题的行是

NSString *link = [[request URL] absoluteString];

Before I getting an unmodified copy of the clicked link。在iOS3和iOS4中仍然是一样的。但在 iOS5 上它仅转换为小写。 下一行

if ([link hasPrefix:@"playSound:"]) {

永远不会成真。所以我必须将代码更改为

- (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType {
    // Only do something if a link has been clicked
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        NSString *link = [[[request URL] absoluteString] lowercaseString];
        if ([link hasPrefix:@"playsound:"]) {
            [PlayAudio playAudio: [link substringFromIndex:10]];
            return NO;
        }
    }
    return YES;
}

Now I'm== 在所有版本的 iOS 上都为小写,因此与小写字符串进行比较。

您认为:新的 iOS 版本有必要进行这样的更改吗?

Two of my programs available in the AppStore for months and running without any problems on iOS3 and iOS4 are not compatible with iOS5.

It seems to me that Apple has changed some things to make the life of developers a little bit harder.

One of the problems is this:

- (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType {
    // Only do something if a link has been clicked
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        NSString *link = [[request URL] absoluteString];
        if ([link hasPrefix:@"playSound:"]) {
            [PlayAudio playAudio: [link substringFromIndex:10]];
            return NO;
        }
    }
    return YES;
}

The line that make the problem is

NSString *link = [[request URL] absoluteString];

Before I got an unmodified copy of the clicked link. In iOS3 and iOS4 it is still the same. But on iOS5 it is converted to lowercase only.
The next Line

if ([link hasPrefix:@"playSound:"]) {

never becomes true. So I had to change the code to

- (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType {
    // Only do something if a link has been clicked
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        NSString *link = [[[request URL] absoluteString] lowercaseString];
        if ([link hasPrefix:@"playsound:"]) {
            [PlayAudio playAudio: [link substringFromIndex:10]];
            return NO;
        }
    }
    return YES;
}

Now I'm expecting lowercase on all versions of iOS and therefore compare with a lowercase string.

What do you think: Are changes like this on a new iOS version neccessary?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文