I am trying to implement UIPickerView
and I have almost done it. But when I click on text field, picker view appears behind the text field. Here are the snapshots before and after showing picker view.
Before clicking on text field.
After clicking on the text field.
Here you can see that picker view is behind the text field. I want it to be on top.
EDIT Here is the code I am using to show picker view:
-(void) showPickerView
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.50];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[self.view bringSubviewToFront:self.picker];
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if(iOSDeviceScreenSize.height == 480)
{
CGRect frame = self.picker.frame;
frame.origin.y = 151.0;
self.picker.frame = frame;
frame = self.toolBar.frame;
frame.origin.y = 107.0;
self.toolBar.frame = frame;
}
else if(iOSDeviceScreenSize.height == 568)
{
CGRect frame = self.picker.frame;
frame.origin.y = 239.0;
self.picker.frame = frame;
frame = self.toolBar.frame;
frame.origin.y = 195.0;
self.toolBar.frame = frame;
}
[UIView commitAnimations];
}
I solved the issue. In fact it was a plum mistake. I placed the pickerView
before other views. So when it appears on screen, it appears behind the textfield
. I had to put it at the bottom place in my .nib
file.
In iOS, the view added before will go behind other views. I missed this concept.