- (void) viewDidLoad {
dataArray = [[NSMutableArray alloc] initWithObjects: @ "A +", @ "A -", @ "B +", @ "B -", @ "O +" , @ "O-", nil];
bloodGroup = [[UITextField alloc] initWithFrame: CGRectMake (10, logoImg.frame.origin.y + logoImg.frame.size.height + 45, screenWidth-20 , 50)];
bloodGroup.borderStyle = UITextBorderStyleRoundedRect;
bloodGroup.font = [UIFont systemFontOfSize: 15];
bloodGroup.placeholder = @ "Пожалуйста, выберите ваш вариант ";
bloodGroup.delegate = self;
[self.view addSubview: bloodGroup];
txtField1 = [[UITextField alloc] initWithFrame: CGRectMake (10, ansField1. frame.origin.y + ansField1.frame.size.height + 45, screenWidth-20, 50)];
txtField1.borderStyle = UITextBorderStyleRoundedRect;
txtField1.font = [UIFont systemFontOfSize: 15];
txtField1.placeholder = @ "Пожалуйста, выберите ваш вариант";
txtField1.delegate = self;
[self.view addSubview: txtField1];
* 10 28 * txtField2 = [[UITextField alloc] initWithFrame: CGRectMake (10, ansField2.frame.origin.y + ansField2.frame.size.height + 45, screenWidth-20, 50)];
txtField2.borderStyle = UITextBorderStyleRoundedRect;
txtField2.font = [UIFont systemFontOfSize: 15];
txtField2.placeholder = @ "Пожалуйста, выберите ваш вариант";
txtField2.delegate = self;
[self.view addSubview: txtField2];
myPickerView = [[UIPickerView alloc] init];
[myPickerView setDataSource: self];
[myPickerView setDelegate: self];
myPickerView.showsSelectionIndicator = YES;
bloodGroup.inputView = myPickerView;
bloodGroup.inputAccessoryView = toolBar;
* 1052 / txtField1
txtField1.inputView = myPickerView;
txtField1.inputAccessoryView = toolBar;
txtField2.inputView = myPickerView;
txtField2.inputAccessory = =
}
- (NSInteger) numberOfCo mponentsInPickerView: (UIPickerView *) pickerView {
if (isBloodGroupFieldSelected) {
return 1;
}
else if (! isBloodGroupFieldSelected) {
return 1;
}
else if (! IsGenderGroupFieldSelected)
{
return 1;
}
return 0;
}
- (NSInteger) pickerView: (UIPickerView *) pickerView numberOfRowsInComponent: (NSInteger) компонент {
if (isBloodGroupFieldSelected) {
return [dataArray count];
}
else if (! IsBloodGroupFieldSelected)
{
return [dataArray count];
}
иначе, если (! IsGenderGroupFieldSelected)
{
return [dataArray count];
}
return 0;
}
- (NSString *) pickerView: (UIPickerView *) pickerView titleForRow: (NSInteger) строка forComponent: (NSInteger) компонент {
if ( isBloodGroupFieldSelected)
* 1 122 * {
вернуть dataArray [row];
}
else if ((! IsBloodGroupFieldSelected) && (isGenderGroupFieldSelected))
{
вернуть dataArray [row];
}
else if (! IsGenderGroupFieldSelected)
{
вернуть dataArray [row];
}
return 0;
}
- (void) pickerView: (UIPickerView *) pickerView didSelectRow: (NSInteger) строка inComponent: (NSInteger) component {
if (isBloodGroupFieldSelected) {
bloodGroup.text = dataArray [row];
}
else if ((! IsBloodGroupFieldSelected) && (isGenderGroupFieldSelected) )
{
txtField1.text = dataArray [row];
}
else if (! IsGenderGroupFieldSelected)
{
txtField2.text = dataArray [row];
}
}
- (void) textFieldDidBeginEditing: (UITextField *) textField {
if (textField == bloodGroup) {
isBloodGroupFieldSelected = YES;
}
else if (textField == txtField1) {
isBloodGroupFieldSelected = NO;
isGenderGroupFieldSelected = YES;
}
еще if (textField == txtField2) {
isGenderGroupFieldSelected = NO;
isBloodGroupFieldSelected = NO;
}
[myPickerView reloadAllComponents];
}
- (void) textFieldDidBeginEditing: (UITextField *) textField {
if (textField == bloodGroup) {
isBloodGroupFieldSelected = YES;
} else if (textField == txtField1) {
isBloodGroupFieldSelected = NO;
isGenderGroupFieldSelected = YES;
}
еще if (textField == txtField2) {
isGenderGroupFieldSelected = NO;
isBloodGroupFieldSelected = NO;
}
[myPickerView reloadAllComponents];
}
- (void) viewWillAppear: (BOOL) анимированный {
[ super viewWillAppear: animated];
[myPickerView selectRow: 0 inComponent: 0 animated: YES];
}
- (void) сделано: (id) отправитель
{
[myPickerView selectRow: 0 inComponent: 0 animated: YES]; // 27/04/2020
[bloodGroup resignFirstResponder];
[txtField1 resignFirstResponder];
[txtField2 resignFirstResponder];
}