Objective-c iphone 应用程序,解析超链接的按钮问题
我的申请的另一个问题是程序简单。我想要一个按钮,如果您按下该按钮,则会打开与相关文章相关的链接。我已按照我理解的说明进行操作,但我无法理解为什么该链接不起作用。
- (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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论