alskipp / ASValueTrackingSlider

A UISlider subclass that displays the slider value in a popup view
MIT License
1.84k stars 235 forks source link

Swift, PopUp is hidden by tableview cell. #52

Open CapeFurSeal opened 8 years ago

CapeFurSeal commented 8 years ago

I read a similar post in the issues about someone having the same problem, except they had a jail broken phone and this was a while back.

The example project in Objective C is working but when I tried to implement it in my Swift project the pop over was being slightly hidden.

The delegate functions are being called.

screen shot 2016-06-17 at 12 15 39 pm

Any guesses?

    func sliderWillDisplayPopUpView(slider:ASValueTrackingSlider?) {
    self.superview?.bringSubviewToFront(self)
    } 
alskipp commented 8 years ago

Not sure : ( My best guess is it's something to do with the gradient in your tablecells. The method to ensure the popup shows above other tablecells is admittedly a bit of a hack, I just can't think of a better way. What is the type of supeview in your use case? If it's not UITableView you might need superview.superview which is truly horrible. 🙀

ghost commented 7 years ago

@alskipp I tried to implement it in a static tableview using swift 3. But I failed to connect the outlet from storyboard to my UITableViewCell subclass. (I tried to change my tableview to dynamic instead of static, everything works fine.)

Without the outlet I don't know how to prevent the slider being obscured by the cell. I tried to hack around in my TableViewController subclass but with no luck :( Do you know is there any way to solve it?

alskipp commented 7 years ago

Hi @rx2130, it is possible to get things working with a static tableview. I struggled a little initially, but the thing to check is that the cell has Clips to bounds set to false. Also ensure that the IBOutlet in the SliderCell subclass is connected to the slider.

snap

I've just added a new static tableview screen to the example project, please take a look at that – it's all done purely in Interface Builder.

ghost commented 7 years ago

@alskipp Thanks for adding the new demo! I got it to work in the end but there're couple thing worth to point out.

alskipp commented 7 years ago

@rx2130 Glad it's working 👍 When I said "purely" in Interface Builder, I suppose that was a bit of a lie : )

What I really meant was that you don't need to add any code to your tableview controller, but you do need to declare the IBOutlet in the table cell subclass and handle the delegate method there.

No idea why keeping Clips To Bounds to true still works!?