如何在 iPhone 中的 URL 中传递 PickerValue

发布于 2024-12-09 04:53:17 字数 824 浏览 1 评论 0原文

arrayNo = [[NSMutableArray alloc] init];             //pickerview radius array
//[arrayNo addObject:@" Radius "];

[arrayNo addObject:@" 10 "];
[arrayNo addObject:@" 15000 "];
[arrayNo addObject:@" 20000 "];
[pickerView selectRow:1 inComponent:0 animated:NO];
[addressField resignFirstResponder];
radius.text= [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]];

我想在半径处的以下网址中传递上述半径选择器,

NSString *url = [NSString stringWithFormat:@"http://.............../phpsqlsearch_genxml.php?lat=%f&lng=%f&radius=%f",lati,longi,radius];

我尝试在按钮单击事件上使用以下代码,但不起作用。

NSString * radius = [[[NSString alloc] initWithFormat:@"%f",[arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]]]autorelease];

我应该为此编写什么代码......提前致谢

arrayNo = [[NSMutableArray alloc] init];             //pickerview radius array
//[arrayNo addObject:@" Radius "];

[arrayNo addObject:@" 10 "];
[arrayNo addObject:@" 15000 "];
[arrayNo addObject:@" 20000 "];
[pickerView selectRow:1 inComponent:0 animated:NO];
[addressField resignFirstResponder];
radius.text= [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]];

I want to pass the above radius picker in following url at radius

NSString *url = [NSString stringWithFormat:@"http://.............../phpsqlsearch_genxml.php?lat=%f&lng=%f&radius=%f",lati,longi,radius];

I tried with following code on button click event but not working.

NSString * radius = [[[NSString alloc] initWithFormat:@"%f",[arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]]]autorelease];

What code should I write for the same...thanks in advance

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌路终见情 2024-12-16 04:53:17

您可以将代码更改为,

float radius = [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]] floatValue];
NSString *url = [NSString stringWithFormat:@"http://.............../phpsqlsearch_genxml.php?lat=%f&lng=%f&radius=%f",lati,longi,radius];

并且,您不需要最后一行 NSString * radius = ...

You can change your code to,

float radius = [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]] floatValue];
NSString *url = [NSString stringWithFormat:@"http://.............../phpsqlsearch_genxml.php?lat=%f&lng=%f&radius=%f",lati,longi,radius];

And, you don't need the last line NSString * radius = ....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文