我的rootViewController
中有以下代码。在prepareForSegue
方法中,我找出在该页面的NSObject
中选择了哪个UIPickerView
,并填充了UITextField
中的DataViewController
。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
DataViewController *detailView = segue.destinationViewController;
if([segue.identifier isEqualToString:@"dataViewSegue"])
{
for(NSString *parent in dictionaryKeys) {
NSDictionary *parentData = [dictionaryFromPlist objectForKey:parent];
if ([parentData objectForKey:@"Name"]== currentSite) {
NSLog(@"found it");
detailView.nameText = [parentData valueForKey:@"Name"];
detailView.descriptionText = [parentData valueForKey:@"Description"];
detailView.positionText =[parentData valueForKey:@"Position"];
detailView.latitudeText = [parentData valueForKey:@"Latitude"];
detailView.longitudeText = [parentData valueForKey:@"Longitude"];
detailView.gridRefText = [parentData valueForKey:@"GridRef"];
detailView.radioText = [parentData valueForKey:@"Radio"];
detailView.elevationText = [parentData valueForKey:@"Elevation"];
detailView.lengthText = [parentData valueForKey:@"Length"];
detailView.widthText = [parentData valueForKey:@"Width"];
detailView.phoneText = [parentData valueForKey:@"Phone"];
detailView.bestApproachText = [parentData valueForKey:@"BestApproach"];
detailView.gpsText =[parentData valueForKey:@"GPS"];
detailView.gridRefText = [parentData valueForKey:@"GPS"];
detailView.windstockState = [parentData valueForKey:@"Windsock"];
detailView.forbiddenSectorsText = [parentData valueForKey:@"ForbiddenSectors"];
detailView.hazardsText = [parentData valueForKey:@"Hazards"];
detailView.aircraftsustainabilityText = [parentData valueForKey:@"Sustainability"];
detailView.notesText = [parentData valueForKey:@"Notes"];
detailView.clearareaState = [parentData valueForKey:@"ClearArea"];
detailView.helipadState = [parentData valueForKey:@"Helipad"];
detailView.tdpText = [parentData valueForKey:@"TDP"];
detailView.ldpText = [parentData valueForKey:@"LDP"];
detailView.surveyingoperatorText = [parentData valueForKey:@"SurveyingOperator"];
detailView.surveyorText = [parentData valueForKey:@"Surveyor"];
detailView.authorisedbyText = [parentData valueForKey:@"AuthorisedBy"];
detailView.surveyordateText = [parentData valueForKey:@"SurveyorDate"];
detailView.authorisationdateText = [parentData valueForKey:@"AuthorisationDate"];
detailView.dataArray = self.landingSites;
}
}
}
}
但是,在DetailViewController
上,我有另一个UIPicker
,用户可以再次选择NSObject
。
我的问题是如何根据UITextField
中选择的NSObject
再次填充DataViewController
?请注意,数据来自Plist
。请帮忙。感谢
答案 0 :(得分:0)
以下是设置textfield内容的代码...
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent: (NSInteger)component
{
return [arrOfCategory count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *titleRow;
titleRow = [NSString stringWithFormat:@"%@", [arrOfCategory objectAtIndex:row]];
yourTextField.text = titleRow;
return titleRow;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
selectedRow = row;
}
享受编码