gpt4 book ai didi

ios - 如何在 iPhone 的 webview 中从字符串中打开 url

转载 作者:IT王子 更新时间:2023-10-29 08:04:46 26 4
gpt4 key购买 nike

我只想从我的字符串中打开一个 url我的字符串已经有了我只想在 UIWebView

中显示的 url
myString=http://maps.google.com/maps?zoom=8&sensor=false&lci=transit&layer=traffic&saddr=1.31224,103.865&daddr=1.310664,103.857132

NSString *urlString = [myString absoluteString];
NSString *urlAddress =myString;//
NSURL *url = [NSURL URLWithString:urlString ];

NSLog(@" url is %@",url); its null
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];


NSLog(@" url req is %@",url);
//Load the request in the UIWebView.
[webe loadRequest:requestObj];

我遇到了这个错误

se&lci=transit&layer=traffic&saddr=1.31224,103.865&daddr=1.310664,103.857132
2010-08-02 13:20:08.253 Wat2Eat[5332:207] *** -[NSCFString absoluteString]: unrecognized selector sent to instance 0x1ac570
2010-08-02 13:20:08.267 Wat2Eat[5332:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString absoluteString]: unrecognized selector sent to instance 0x1ac570'
2010-08-02 13:20:08.283 Wat2Eat[5332:207] Stack: (

最佳答案

将此添加到您的方法中:

    NSString *urlAddress = @"http://myurl.com";

//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];

//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
[detailWebView loadRequest:requestObj];

关于ios - 如何在 iPhone 的 webview 中从字符串中打开 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3385210/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com