ios - Add a drop down suggestion below a UISearchbar and UITextfields -


in ios app, there 3 separate text entry fields. 1 in searchbar , 2 in uialertview(that has 2 entry fields). need give drop down menu below fields can give suggestions user. have data needed in array(all 3 fields need same array suggestion). how this? should programmatically create uitableview appear below textfields(with basic cell, containing 1 text field) ? if so, how can right frame? or else, other method should refer?

here simple example. here taking 1 uitextfield. when becomes first responder, showing drop down i.e., uitableview . when object selected table view drop down collapse.

- (void)viewdidload {    [super viewdidload];    // additional setup after loading view, typically nib.      mutarr=[[nsmutablearray alloc]init];    [mutarr addobject:@"object1"];    [mutarr addobject:@"object2"];    [mutarr addobject:@"object3"];    [mutarr addobject:@"object4"];    [mutarr addobject:@"object5"];    [mutarr addobject:@"object6"];    [mutarr addobject:@"object7"];    [mutarr addobject:@"object8"];      txtlist1=[[uitextfield alloc]init];    [txtlist1 setframe:cgrectmake(30, 100, 260, 30)];    [txtlist1 settag:100];    [txtlist1 setdelegate:self];    [txtlist1 setbackgroundcolor:[uicolor browncolor]];    [txtlist1 settextcolor:[uicolor whitecolor]];    [self.view addsubview:txtlist1];     tbllist=[[uitableview alloc]init];    [tbllist setdelegate:self];    [tbllist setdatasource:self];    [self.view addsubview:tbllist];  }  -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {    return mutarr.count; }     -(uitableviewcell*)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath  {     uitableviewcell *cell=[[uitableviewcell alloc]init];    [cell setbackgroundcolor:[uicolor graycolor]];    cell.textlabel.textcolor=[uicolor whitecolor];    cell.textlabel.text=[mutarr objectatindex:indexpath.row];     return cell;   }   - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {    uitableviewcell *cell=[tbllist cellforrowatindexpath:indexpath];    txtlist1.text=cell.textlabel.text;     [txtlist1 resignfirstresponder];    [self collapsetableview];   }   - (void)textfielddidbeginediting:(uitextfield *)textfield {    [textfield resignfirstresponder];     if (textfield.tag==100)    {        cgrect rect=tbllist.frame;        if (rect.size.height==0)        {           [self expandtableview];         }    }  }   -(void)collapsetableview {     [tbllist setframe:cgrectmake(30, 130, 260, 120)];    [uiview animatewithduration:0.3 delay:0.0 options:uiviewanimationoptiontransitionnone                  animations:^{         [tbllist setframe:cgrectmake(30, 130, 260, 0)];      }    completion:^(bool finished)     {        nslog(@"comleted");     }];  }  -(void)expandtableview {    [tbllist setframe:cgrectmake(30, 130, 260, 0)];    [uiview animatewithduration:0.3 delay:0.0 options:uiviewanimationoptiontransitionnone                  animations:^{        [tbllist setframe:cgrectmake(30, 130, 260, 200)];      }     completion:^(bool finished)     {        nslog(@"comleted");     }];  } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -