1
-(void)textFieldDidBeginEditing:(UITextField *)myTextField{
[myTextField resignFirstResponder];
UITextField *tempbtn;
tempbtn = myTextField;
btntagvalue = tempbtn.tag;
if(btntagvalue == 1)
{
if ((quantitypicker.hidden == NO) || (frequencyvalues.hidden == NO) ||(daysnum.hidden ==
NO)) {
[quantitypicker setHidden:YES];
[frequencyvalues setHidden:YES];
[daysnum setHidden:YES];
}
if ((quantitypicker.hidden == NO)||(frequencyvalues.hidden==NO)||(daysnum.hidden==YES))
{
[quantitypicker setHidden:YES];
[frequencyvalues setHidden:YES];
}
if ((quantitypicker.hidden==YES)||(frequencyvalues.hidden==NO)||(daysnum.hidden==NO))
{
[frequencyvalues setHidden:YES];
[daysnum setHidden:YES];
}
if ((quantitypicker.hidden==NO)||(frequencyvalues.hidden==YES)||(daysnum.hidden==NO))
{
[quantitypicker setHidden:YES];
[daysnum setHidden:YES];
}
datevalues = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 150, 320, 280)];
datevalues.datePickerMode = UIDatePickerModeDateAndTime;
datevalues.minimumDate=[NSDate date];
[self.view addSubview:datevalues];
[datevalues addTarget:self
action:@selector(datepicker:)forControlEvents:UIControlEventValueChanged];
[datevalues release];
}
if (btntagvalue == 2) {
if ((datevalues.hidden == NO) || (frequencyvalues.hidden == NO) ||(daysnum.hidden == NO)) {
[datevalues setHidden:YES];
[frequencyvalues setHidden:YES];
[daysnum setHidden:YES];
}
if ((datevalues.hidden == NO) || (frequencyvalues.hidden == NO) ||(daysnum.hidden == YES)) {
[datevalues setHidden:YES];
[frequencyvalues setHidden:YES];
}
if ((datevalues.hidden == YES) || (frequencyvalues.hidden == NO) ||(daysnum.hidden == NO)) {
[frequencyvalues setHidden:YES];
[daysnum setHidden:YES];
}
if ((datevalues.hidden == NO) || (frequencyvalues.hidden == YES) ||(daysnum.hidden == NO)) {
[datevalues setHidden:YES];
[daysnum setHidden:YES];
}
quantitypicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,190,320,220)];
if ([meditype isEqualToString:@"Capsules"]) {
quantitytype = [[NSMutableArray
alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",nil];
}
if ([meditype isEqualToString:@"Eyedrops"]||[meditype isEqualToString:@"Eardrops"]||\
[meditype isEqualToString:@"Nosedrops"]) {
quantitytype = [[NSMutableArray
alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",nil];
}
if ([meditype isEqualToString:@"Inhaler"]) {
quantitytype = [[NSMutableArray alloc]initWithObjects:@"1 dose",@"2 doses",@"3
doses",@"4 doses",@"5 doses",@"6 doses",@"7 doses",@"8 doses",@"9 doses",@"10 doses",nil];
}
if ([meditype isEqualToString:@"Syrup"]) {
quantitytype = [[NSMutableArray alloc]initWithObjects:@"1 tablespoon",@"2
tablespoon",@"3 tablespoon",@"4 tablespoon",@"5 tablespoon",@"6 tablespoon",@"7
tablespoon",@"8 tablespoon",@"9 tablespoon",@"10 tablespoon",nil];
}
if ([meditype isEqualToString:@"Oils"]) {
quantitytype = [[NSMutableArray alloc]initWithObjects:@"1 ml",@"2 ml",@"3 ml",@"4
ml",@"5 ml",@"6 ml",@"7 ml",@"8 ml",@"9 ml",@"10 ml",nil];
}
if ([meditype isEqualToString:@"Injections"]) {
quantitytype = [[NSMutableArray
alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",nil];
}
quantitypicker.delegate = self;
quantitypicker.showsSelectionIndicator = YES;
quantitypicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:quantitypicker];
}
if (btntagvalue ==3) {
if ((datevalues.hidden == NO) || (quantitypicker.hidden == NO) ||(daysnum.hidden == NO)) {
[datevalues setHidden:YES];
[quantitypicker setHidden:YES];
[daysnum setHidden:YES];
}
if ((datevalues.hidden == NO) || (quantitypicker.hidden == NO) ||(daysnum.hidden == YES)) {
[datevalues setHidden:YES];
[quantitypicker setHidden:YES];
}
if ((datevalues.hidden == YES) || (quantitypicker.hidden == NO) ||(daysnum.hidden == NO)) {
[quantitypicker setHidden:YES];
[daysnum setHidden:YES];
}
if ((datevalues.hidden == NO) || (quantitypicker.hidden == YES) ||(daysnum.hidden == NO)) {
[datevalues setHidden:YES];
[daysnum setHidden:YES];
}
frequencyvalues = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 190, 320, 220)];
arrayfreq = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",
@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",
@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24", nil];
frequencyvalues.delegate = self;
frequencyvalues.showsSelectionIndicator = YES;
frequencyvalues.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:frequencyvalues];
}
if (btntagvalue ==4) {
if ((datevalues.hidden == NO) || (frequencyvalues.hidden == NO) ||(quantitypicker.hidden ==
NO)) {
[datevalues setHidden:YES];
[frequencyvalues setHidden:YES];
[quantitypicker setHidden:YES];
}
if ((datevalues.hidden == NO) || (frequencyvalues.hidden == NO) ||(quantitypicker.hidden ==
YES)) {
[datevalues setHidden:YES];
[frequencyvalues setHidden:YES];
}
if ((datevalues.hidden == YES) || (frequencyvalues.hidden == NO) ||(quantitypicker.hidden ==
NO)) {
[frequencyvalues setHidden:YES];
[quantitypicker setHidden:YES];
}
if ((datevalues.hidden == NO) || (frequencyvalues.hidden == YES) ||(quantitypicker.hidden ==
NO)) {
[datevalues setHidden:YES];
[quantitypicker setHidden:YES];
}
daysnum = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 190, 320, 220)];
arraytime = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",
@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",
@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",
nil];
daysnum.delegate = self;
daysnum.showsSelectionIndicator = YES;
daysnum.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:daysnum];
}
}
私の問題を見ていただきありがとうございます。私はそれぞれのループで条件を使って解決しました。私は上記のコードを編集しました。 – Nitin
thats素晴らしいNitinあなたの問題を解決しました..あなたが編集したコードの答えを投稿すれば素晴らしいでしょう!それは将来誰かを助けるかもしれない:) – Saurabh