1

I have been newly using UIPickerView, while showing UIPickerView do I need to hide all other controls in the same view, because I am getting issue like this. please see the image below

button behind is showing front. how to avoid this issue. Any idea?

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
Newbee
  • 3,231
  • 7
  • 42
  • 74
  • 1
    Where are you creating your picker and where are you adding it to the view? And are you using the picker as input for a `UITextField`? You might want to set the picker as `UITextField`'s `inputView` in this case. – Michael Ochs Oct 19 '12 at 11:20
  • I added picker view from IB in hidden state and just showing while clicking button – Newbee Oct 19 '12 at 11:22

2 Answers2

2
[self.view bringSubviewToFront:yourPickerView];
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • you set alpha for UIPickerView?? – Paras Joshi Oct 19 '12 at 11:17
  • no I added picker view from IB in hidden state and just showing while clicking button. – Newbee Oct 19 '12 at 11:20
  • ok when you show the pickerview at that time add above method and also yourPickerView.alpha = 1.0; this line try it , i think something wrogn go here.. – Paras Joshi Oct 19 '12 at 11:22
  • No its not working, I thing while adding the button I had added over the picker view I guess. I have to check – Newbee Oct 19 '12 at 11:28
  • yes and where you add button?? and if you add button any where but if you write above method bringToSubview then your pickerview must show as a superview , mate.. – Paras Joshi Oct 19 '12 at 11:30
  • Ya I removed from IB, and added programatically, it is working now, thanks dude.... – Newbee Oct 19 '12 at 11:36
0

Hi i think you have to set the frame for picker view. Below code is for uipickerview, plz modify as you wish.

-(IBAction)pickButtonpressed:(id)sender

{

UIActionSheet *asheet = [[UIActionSheet alloc] initWithTitle:@"Select Distance" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Select", nil];

[asheet setTag:200];

UIPickerView *statePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, 0, 0)];

statePicker.delegate=self;

statePicker.showsSelectionIndicator = YES;

[statePicker setTag:11];

[asheet addSubview:statePicker];

[asheet showInView:[self.view superview]]; //note: in most cases this would be just self.view, but because I was doing this in a tabBar Application, I use the superview.

[asheet setBounds:CGRectMake(0,0,320, 700)];

[asheet setFrame:CGRectMake(0, 117, 320, 383)];

NSArray *subviews = [asheet subviews];

[[subviews objectAtIndex:1] setFrame:CGRectMake(20, 266, 280, 46)]; 

[[subviews objectAtIndex:2] setFrame:CGRectMake(20, 317, 280, 46)];

}

Mahesh Peri
  • 1,689
  • 2
  • 14
  • 24