[英]iPhone Linking to an iTunes page
I found a page ( http://itunes.apple.com/linkmaker ) to get the iTunes url for a specific page which I assume should direct the user out of my app and into the corresponding page in the app store. 我找到了一个页面( http://itunes.apple.com/linkmaker )以获取特定页面的iTunes URL,我认为该页面应将用户引导出我的应用程序并进入应用商店中的相应页面。
I have never done this or any other UIWebView stuff but after some searching I found some code that I thought would work that uses UIApplication.h. 我从未做过此事或其他任何UIWebView事,但经过一番搜索,我发现一些我认为可以使用UIApplication.h的代码。
My code is: 我的代码是:
#import <UIApplication.h>
//...in a tableView....
case 8:
- (BOOL)openURL:(NSURL *) http://itunes.apple.com/us/app/lockbox-pro/id288460603?mt=8&uo=4;
break;
openURL has an error saying that it is undeclared - but I imported the UIApplication.h file. openURL有一个错误消息,说它未声明-但我导入了UIApplication.h文件。 Then I saw that the UIApplication import also had an error on it. 然后我看到UIApplication导入也有一个错误。 I don't think that I want to use UIWebView because from what I understand, that opens up the URL in the app itself - I want to direct the user to the App Store. 我不希望使用UIWebView,因为据我了解,这会在应用程序本身中打开URL-我想将用户定向到App Store。 Where am I going wrong? 我要去哪里错了?
EDIT: Okay, I changed it to a simple button that is supposed to close the app and bring the user to the itunes page: 编辑:好的,我将其更改为一个简单的按钮,该按钮应该关闭应用程序并将用户带到iTunes页面:
- (IBAction) pressedFull {
[[UIApplication sharedApplication] openURL:[NSURL urlWithString:@"http://www.google.com"]];
} }
I linked it in IB - it still crashes the app when the user clicks on it. 我在IB中链接了它-用户单击它仍会使应用程序崩溃。
Your code has a number of things wrong in just one line. 您的代码在一行中有很多错误。 First, you're typing the method signature rather than using the method properly (ie, sending a message to an object). 首先,您要键入方法签名而不是正确使用方法(即,将消息发送到对象)。 Second, you're not enclosing the string. 其次,您不包含字符串。
Try this: 尝试这个:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://yoururlhere"]];
With respect, you should review the Learning Objective-C: a Primer thoroughly until you are more comfortable with the syntax as well. 顺便说一句 ,您应该彻底阅读《 Learning Objective-C:入门》,直到您对语法也更加满意为止。 A quick look at some of your other questions suggests this is your biggest issue. 快速浏览一下您的其他一些问题,这表明这是您最大的问题。 You'll be doing yourself a huge favor by setting all else aside and concentrating on getting Objective-C well and truly under your belt before continuing. 将所有其他事项搁置一旁,然后集中精力让Objective-C真正成为自己的主力军,然后再继续,您将为自己赢得巨大的好处。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.