【问题标题】:How to pass PickerValue in URL in iphone如何在 iphone 的 URL 中传递 PickerValue
【发布时间】:2011-10-12 12:43:04
【问题描述】:
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];

我应该为相同的代码编写什么代码...在此先感谢

【问题讨论】:

    标签: iphone uipickerview nsurl


    【解决方案1】:

    您可以将代码更改为,

    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 = ...

    【讨论】:

    • 感谢您的代码。但上面的代码是在“lng”参数而不是半径处传递值。这个怎么设置???
    猜你喜欢
    • 1970-01-01
    • 2012-07-30
    • 2011-08-27
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 2020-04-28
    • 2018-07-05
    • 2011-07-19
    相关资源
    最近更新 更多