0

I've been following (successfully) the following tutorial on how to build a UISlider subclass that draws a visual tracking popup view.

http://blog.neuwert-media.com/2011/04/customized-uislider-with-visual-value-tracking/

My final issue comes to the fact that the popup view is being hidden by other view imageView elements. I've been looking for some sort of display order or preference setting but with no luck that would insist on displaying my popupview above the images.

pkamb
  • 33,281
  • 23
  • 160
  • 191
sapatos
  • 1,292
  • 3
  • 21
  • 44

3 Answers3

0

Try it with this SO Answer:

[parentView bringSubviewToFront:[[parentView subviews] objectAtIndex:0]];
// or
[parentView bringSubviewToFront:popupView];
Community
  • 1
  • 1
Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
0

I would suggest adding the popover as a subview to the application's keyWindow so that it is above everything. This is likely the expected behavior to the user. Something like:

- (void)setPopoverVisible:(BOOL)visible {
    if (visible) {
        [self.popover removeFromSuperview];
        UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
        [keyWindow addSubview:self.popover];
    }
    [UIView animateWithDuration:0.15
                          delay:0
                        options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         self.popover.alpha = (visible ? 1 : 0);
                     }
                     completion:^(BOOL finished) {
                         if (!visible) {
                             [self.popover removeFromSuperview];
                         }
                     }];
}

Remember when positioning the popover to convert the rect or point (whatever you use to position the slider) to the keyWindow's bounds. For example:

- (void)positionPopover {
    // Calculate newPopoverCenter in self.bounds
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    self.popover.center = [self convertPoint:newPopoverCenter toView:keyWindow];
}
colinbrash
  • 481
  • 2
  • 11
0

A more modern approach can be found here: https://github.com/alskipp/ASValueTrackingSlider. Maybe it will solve the issue you are having.

koen
  • 5,383
  • 7
  • 50
  • 89