Objective-c iphone 应用程序,解析超链接的按钮问题

发布于 2024-09-16 22:20:32 字数 857 浏览 14 评论 0原文

我的申请的另一个问题是程序简单。我想要一个按钮,如果您按下该按钮,则会打开与相关文章相关的链接。我已按照我理解的说明进行操作,但我无法理解为什么该链接不起作用。

- (IBAction)link:(id)sender {
WebViewController *view = [[WebViewController alloc] initWithNibName:@"WebViewController" 
                                                              bundle:nil];
[[self navigationController]pushViewController:view 
                                      animated:YES];
NSString *urlAddress = [item objectForKey:@"link"];
NSLog(@"urlad = %@", urlAddress);
NSURL *url = [[NSURL alloc] initWithString: urlAddress];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSLog(@"url = %@", url);
[[view webView] loadRequest:request];

[urlAddress release];
[url release];
[view release];}

我尝试进一步调查这一点,但没有运气(NSLogs)。我可以看出“链接”正在进入 urlAddress 字符串,但 url NSURL 不会接受字符串转换。这是最令人恼火的。

如果有人可以提供帮助,我将不胜感激。

Another problem for me with my application is a simple procedure. I want to have a button which, if you press, opens the link associated with the article in question. I have followed instructions that i understand, but I am having trouble understanding why the link will not work.

- (IBAction)link:(id)sender {
WebViewController *view = [[WebViewController alloc] initWithNibName:@"WebViewController" 
                                                              bundle:nil];
[[self navigationController]pushViewController:view 
                                      animated:YES];
NSString *urlAddress = [item objectForKey:@"link"];
NSLog(@"urlad = %@", urlAddress);
NSURL *url = [[NSURL alloc] initWithString: urlAddress];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSLog(@"url = %@", url);
[[view webView] loadRequest:request];

[urlAddress release];
[url release];
[view release];}

I have tried investigating this further, but with no luck (The NSLogs). I can tell that the "link" is getting into the urlAddress string, but the url NSURL will not accept the string conversion. It is most irritating.

If anyone could help, i would be most grateful.

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

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

发布评论

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