2011-10-12 17 views
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]]; 

我想通過上面的半徑選擇器在以下網址在半徑如何通過PickerValue在URL中的iphone

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]; 

我應該寫什麼代碼一樣的...在此先感謝

回答

0

你可以改變你的代碼,

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

+0

感謝您的代碼。但上面的代碼是通過「lng」參數而不是半徑傳遞值。我怎樣才能設置? –