我有一个tableview
有5行,当我选择一行时,它在下一页打开一个UIPickerView
来选择选项,同样的事情发生在5行。现在我想要,Pickervalue ,它应该反映在我选择的特定行(右侧)
我在同一页面上有一个按钮,用于对所选行值(UIPicker值)执行。如何在Button.to中选择从UIPicker
获取的行值
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row==0){
Picker1 *logInController = [[Picker1 alloc] init];
[[self navigationController] pushViewController:logInController animated:YES];
}
if(indexPath.row==1){
Picker2 *logInController = [[Picker2 alloc] init];
[[self navigationController] pushViewController:logInController animated:YES];
}
}
如上所述我打开了UIPIcker
并选择了选项。
IN PICKER1.m
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// update label text to show selected option
NSString* string=[NSString stringWithFormat:@"you are selected %@",[list objectAtIndex:row]];
label.text=string;
}
- (void)viewDidLoad
{
[super viewDidLoad];
list =[[NSMutableArray alloc]init];
[list addObject:@"GPS"];
[list addObject:@"NONE"];
}
答案 0 :(得分:1)