mercredi 25 mars 2015

Setting inputAccessoryView for a UitextField

I just want to make the UITextField to go up when keyboard was presented. I achieved it by setting the frame of UITextField after keyboard was presented. It is working for ordinary cases. But, if user enabled prediction in default keyboard then predictive text area gets placed above the UITextField. In that case I want the text field to move up. I tried setting inputAccessoryView of textfield. But app crashed with no report .So how can I set inputAccessoryView of textfield to achieve my requirement.



textField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, bottomToolbarView.frame.size.width, bottomToolbarView.frame.size.height)];
textField.delegate = self;
textField.textAlignment = NSTextAlignmentCenter;
textField.inputAccessoryView = bottomToolbarView;
[textField setReturnKeyType:UIReturnKeyGo];
[textField setPlaceholder:@"Enter Employee Id"];
[textField setBackgroundColor:[UIColor colorWithRed:1.000 green:0.720 blue:0.611 alpha:1.000]];
[bottomToolbarView addSubview:textField];


Simulator Image




Aucun commentaire:

Enregistrer un commentaire