【发布时间】:2016-05-09 13:27:39
【问题描述】:
我是 IOS 新手,我想根据文本字段中的选择器视图选择显示它们的参数可以作为 Post 方法传递以获取响应并在警报视图中查看。
选取器视图委托:
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if(pickerView.tag == 2){
return arrMsg.count;
}else if(pickerView.tag == 1){
return currencyname1.count;
}
else
{
return from_currency.count;
}
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if(pickerView.tag == 2){
return [arrMsg objectAtIndex:row];
}else if(pickerView.tag == 1){
return [currencyname1 objectAtIndex:row];
}
else
{
return [from_currency objectAtIndex:row];
}
}
- (void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(pickerView.tag ==2){
txtText.text = (NSString *)[arrMsg objectAtIndex:row];
NSLog([arrmsg1 objectAtIndex:row]);
}else if(pickerView.tag ==1){
currency1.text = (NSString *)[currencyname1 objectAtIndex:row];
NSLog([id1 objectAtIndex:row]);
}
else
{
currency2.text = (NSString *)[from_currency objectAtIndex:row];
NSLog([id2 objectAtIndex:row]);
}
}
视频加载:
创建数组:
arrMsg = [json valueForKeyPath:@"Branches.branch_name"];
//NSLog(@"%@",json);
arrmsg1 =[json valueForKeyPath:@"Branches.id"];
firststr = [arrmsg1 componentsJoinedByString:@","];
currencyname1 = [json1 valueForKeyPath:@"Currencies.currency_name"];
id1 = [json1 valueForKeyPath:@"Currencies.id"];
from_currency = [json1 valueForKeyPath:@"Currencies.currency_name"];
id2 = [json1 valueForKeyPath:@"Currencies.id"];
secondstr = [id1 componentsJoinedByString:@","];
thirdstr = [id2 componentsJoinedByString:@","];
NSLog(@"%@",secondstr);
NSLog(@"%@",thirdstr);
str = [NSString stringWithFormat:@"branch_id=%@&from_curr=%@&to_curr=%@&value=%@",firststr,secondstr,thirdstr,fourthstr];
pktStatePicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
pktStatePicker .delegate = self;
pktStatePicker .dataSource = self;
txtText.delegate = self ;
currency1.delegate = self;
currency2.delegate = self;
[ pktStatePicker setShowsSelectionIndicator:YES];
【问题讨论】:
-
显示您的 arrMsg 一次
标签: ios objective-c nsurlconnection uipickerview