1

I am trying to show the picker view immediately after the the viewDidLoad method get called. But, the UITabBar block some parts of picker view from displaying. How to bring the picker view to the front of the UITabBar? The pickerview is a UIView subclass. The code:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.pickerView = [[AllPickerView alloc] initWithdelegate:self];
    [self.pickerView showInView:self.view];

}
Venk
  • 5,949
  • 9
  • 41
  • 52
yong ho
  • 3,892
  • 9
  • 40
  • 81

2 Answers2

1

You can hide tab bar while showing the picker view or can use:

[[UIApplication sharedApplication].keyWindow addSubview:self.pickerView];

or if you want you can add it on TabBarViewController

[self.tabBarController.view addSubview:...]; or 
[self.tabBarController.tabBar addSubview:...];
B.S.
  • 21,660
  • 14
  • 87
  • 109
  • Not the best idea. The pickerview blocks the top navigation bar. And it stays on the top. I want it comes from the bottom with animation. – yong ho Apr 03 '13 at 08:25
  • You can animate it whatever you want using UIView animations – B.S. Apr 03 '13 at 08:37
0

Set frame properly

 [self.pickerView  setFrame:CGRectMake(0, self.view.frame.size.height-self.pickerView .bounds.size.height, self.pickerView .bounds.size.width, pickerView.bounds.size.height)];

Edit:

use add subview instead of showInView

[self.view addSubView:self.pickerView];
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
  • It's not working. The picker view comes from the bottom of the view. – yong ho Apr 03 '13 at 08:23
  • [self.tabBarController.view addSubview:...] the pickerview shows on the top bloking the navigation bar. [self.tabBarController.tabBar addSubview:...] the pickerview shows in the tabbar subview not in the view controller's view. – yong ho Apr 03 '13 at 09:53
  • @yongho : Use both and try – Lithu T.V Apr 08 '13 at 05:58