我有tableview
5 行,当我选择一行时,它会UIPickerView
在下一页打开一个以选择选项,5 行也会发生同样的事情。现在我想要,Pickervalue,它应该反映在特定的行(右侧)上我选择了
我在同一页面上有一个按钮可以对选定的行值(UIPicker 值)执行。如何在 Button.How to give options in Button.to select the Rows values which are take fromUIPicker
- (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
并选择选项。
在 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"];
}