0

in my app i have a Form sheet view which has a two textfields. one of the textfields when tapped a popover with a picker appears. now when the user finishes from the popover, most of the users, tap on the background to dismiss it. even if i place a Done button in the popover, the user reluctantly taps the background. so when i'm tapping the background, the popover disappears. but when i want to edit the other textfield, i have to tap it twice in order to enter the edit mode. it's like when the popover is being presented, there is a layer beneath it and when it disappears the layer stays until i tap the second time to let it go. anybody familiar with this?

HusseinB
  • 1,321
  • 1
  • 17
  • 41

2 Answers2

0

You could create a transparent UIButton on the background when the picker comes up so that when the user taps on the background, you can specify exactly what is to happen.

schlow
  • 155
  • 1
  • 2
  • 11
  • i tried making the popover background a UIControl subclass and use an IBAction method to to fire up when the background is pressed. however, when i tap the background, the method isn't called as if the background doesn't belong to the viewController class of the popover. btw i'm using a segue popover. – HusseinB Apr 09 '13 at 19:49
0

I suggest you block the background to force the user to dismiss via the popover window

IN the view controller that presents the popover...

//when the popover is presented
   UIView* view = [[UIView alloc] initWithFrame:self.view.bounds];
   popOver.passthroughViews = @[view];
   [self.view addSubview:view];

  //when the popover is dismissed
   [[self.view.subviews lastObject] removeFromSuperview];

(this asumes that the viewController's self.view is the background who's touches you want to block)

Similarly, you could implement a view-covering button, with a selector in the viewController:

  UIButton* button = [[UIButton alloc] initWithFrame:self.view.bounds];
  [button addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventAllEvents];
   popOver.passthroughViews = @[button];
   [self.view addSubview:view];

I think that is what you already tried? The missing ingredient would be passthroughViews. By default background interaction is blocked, aside from the dismissing of the popover (which is why you have that 'invisible layer' impression) - passthroughviews allows you to selectively enable those interactions.

foundry
  • 31,615
  • 9
  • 90
  • 125
  • Okay thanks! Btw I'm displaying the popover by a segue and actually there is a pass through option in the inspector of the segue. – HusseinB Apr 10 '13 at 10:21