现有程序无法在iOS5上运行
我的两个程序在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论