2010-04-09 1 views

Répondre

0

Vous utilisez un UIPickerView au lieu d'une liste déroulante.

Modifier: j'ai raté la partie de champ de texte. Vous émulez une zone de liste déroulante.

Vous pouvez utiliser un champ sélecteur + texte et remplir le champ de texte de la pickerView: didSelectRow: inComponent méthode delegat

Edit2: Il y a quelques questions S/O sur ce déjà - en rapport avec UIPickerView bogues

1
-(void)textFieldDidBeginEditing:(UITextField *)textField{ 
[self gotodropdown]; 
} 

-(void)dropdown 
{ 

if(dropDownView==nil && ([copyListOfItems count] > 0)) 
     { 
      dropDownView = [[DropDownView alloc] initWithArrayData:copyListOfItems heightTableView:200 paddingTop:0 paddingLeft:0 paddingRight:0 refView:textField animation:BOTH openAnimationDuration:2 closeAnimationDuration:0.5 ]; 
      dropDownView.delegate = self; 
      [dropDownView openAnimation]; 
      [self addSubview:dropDownView.view]; 
     } 

} 


//dropdown.m 

- (id)initWithArrayData:(NSMutableArray *)data heightTableView:(CGFloat)tHeightTableView paddingTop:(CGFloat)tPaddingTop paddingLeft:(CGFloat)tPaddingLeft paddingRight:(CGFloat)tPaddingRight refView:(UIView*)rView animation:(AnimationType)tAnimation openAnimationDuration:(CGFloat)openDuration closeAnimationDuration:(CGFloat)closeDuration { 

    if ((self = [super init])) { 

     //array=[[NSMutableArray alloc]init]; 
//[array addObjectsFromArray:data]; 
     self.array = [data retain]; 
     NSLog(@"ARRAYIS:%@",data); 
     self.refView = rView; 

     self.paddingTop = tPaddingTop; 

     self.paddingLeft = tPaddingLeft; 

     self.paddingRight = tPaddingRight; 

     self.heightTableView = tHeightTableView; 

     self.open = openDuration; 

     self.close = closeDuration; 

     CGRect refFrame = refView.frame; 

     self.view.frame = CGRectMake(refFrame.origin.x-paddingLeft,refFrame.origin.y+refFrame.size.height+paddingTop,refFrame.size.width+paddingRight, heightTableView); 

     self.view.layer.shadowColor = [[UIColor blackColor] CGColor]; 

     self.view.layer.shadowOffset = CGSizeMake(5.0f, 5.0f); 

     self.view.layer.shadowOpacity =1.0f; 

     self.view.layer.shadowRadius = 5.0f; 
     animationType = tAnimation; 



    } 

    return self; 

} 

utilisez le délégué tableview pour plus de détails

Questions connexes