Comments (19)
OK, I've identified the problem.
The view hierarchy of UITableView is working against us. The bottom UITableViewCell is rendered first and the top cell is rendered last. This means that content protruding outside a UITableViewCell is obscured by the UITableViewCell above.
Does your table view use static cells? If so, there might be a quick fix for you. In the header of your UITableViewController set an IBOutlet to the cell with the slider.
@property (weak, nonatomic) IBOutlet UITableViewCell *sliderCell;
Then bring the cell to the front when it displays.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (cell == self.sliderCell) {
[self.sliderCell.superview bringSubviewToFront:self.sliderCell];
}
}
Let me know if this helps. In the meantime I'll look into a more general solution to the issue.
from asvaluetrackingslider.
Thanks for raising the issue. I'll have a look into it.
I wonder if setting the ‘ clipsToBounds’ property of the UITableViewCell to ‘NO’ would fix the issue? I've not tried this yet, but I will do when I get a spare moment.
from asvaluetrackingslider.
Thanks a lot for your quick reply! Your second solution works like a charm. You made my day ;-)
from asvaluetrackingslider.
I'm glad it helped!
I'll keep the issue open for now because you'll find that if you have 2 sliders in a table view, one above the other, then that solution isn't so effective (the lower slider can still be obscured by the one above).
What I'll need to implement is either a notification or a delegate call back. Something like this:
@protocol ASValueTrackingSliderDelegate <NSObject>
- (void)sliderWillDisplayPopUpView:(ASValueTrackingSlider *)slider;
@end
If you're embedding the slider in a tableView, you'd register as a delegate of the slider and implement the delegate method. You'd then be given the chance to bring the slider’s tableViewCell to the front of the view hierarchy before the popUpView appears.
from asvaluetrackingslider.
The latest commit 6dfeec9 should have solved the issue with TableViews. I've also added a TableView to the example project which demonstrates how it should be used.
To do:
- Update README with UITableView instructions
from asvaluetrackingslider.
This is not working right now in iPad Air (7.0.6) physical device; but YES in iPhone 4S (7.1.2) physical device and all simulators.
You can check it out with the sample app.
from asvaluetrackingslider.
Hi thanks for your input,
I've just tested this on an iPad 3 and there weren't any issues. Do you have any more details about the issue? Is there a specific series of events that causes the unexpected behaviour?
from asvaluetrackingslider.
It happens with my app but also with the sample app. Here is an screenshot. Just run the app, go to tableview sample and move the slider.
from asvaluetrackingslider.
Hmm, that is strange. Which version of ASValueTrackingSlider are you using?
It's going to be difficult for me to track down the problem because when testing on an iPad 3 the TableView Example works as expected for me. Could you add a breakpoint, or an NSLog to confirm that the delegate method is being called in SliderCell.m
in the TableView Example?
This is the method which should ensure the table cell is brought to the front of the view hierarchy:
- (void)sliderWillDisplayPopUpView:(ASValueTrackingSlider *)slider;
{
[self.superview bringSubviewToFront:self];
}
from asvaluetrackingslider.
Here is the version I'm using: 0.9.3
The code that is running:
- (void)sliderWillDisplayPopUpView:(ASValueTrackingSlider *)slider;
{
NSLog(@"Before bringSubviewToFront");
[self.superview bringSubviewToFront:self];
NSLog(@"After bringSubviewToFront");
}
The console results:
2014-07-11 17:59:08.147 ValueTrackingSlider[2004:60b] Before bringSubviewToFront
2014-07-11 17:59:08.148 ValueTrackingSlider[2004:60b] After bringSubviewToFront
2014-07-11 17:59:10.412 ValueTrackingSlider[2004:60b] Before bringSubviewToFront
2014-07-11 17:59:10.413 ValueTrackingSlider[2004:60b] After bringSubviewToFront
2014-07-11 17:59:11.996 ValueTrackingSlider[2004:60b] Before bringSubviewToFront
2014-07-11 17:59:11.998 ValueTrackingSlider[2004:60b] After bringSubviewToFront
What else can I do to help you find out what is happening? I'm your hands.
from asvaluetrackingslider.
Well the delegate method is getting called - which is good. Perhaps there's something unexpected in the view hierarchy? Could you try using the implementation below and see what results you get?
- (void)sliderWillDisplayPopUpView:(ASValueTrackingSlider *)slider;
{
[self.superview bringSubviewToFront:self];
UIView *view = self;
int i = 1;
while (view) {
NSLog(@"%d: %@", i, view.class);
view = view.superview;
i++;
}
}
Here's what I get:
2014-07-11 17:16:05.261 ValueTrackingSlider[4006:60b] Before bringSubviewToFront
2014-07-11 17:16:05.264 ValueTrackingSlider[4006:60b] 1: SliderCell
2014-07-11 17:16:05.266 ValueTrackingSlider[4006:60b] 2: UITableViewWrapperView
2014-07-11 17:16:05.268 ValueTrackingSlider[4006:60b] 3: UITableView
2014-07-11 17:16:05.269 ValueTrackingSlider[4006:60b] 4: UIViewControllerWrapperView
2014-07-11 17:16:05.271 ValueTrackingSlider[4006:60b] 5: UINavigationTransitionView
2014-07-11 17:16:05.273 ValueTrackingSlider[4006:60b] 6: UILayoutContainerView
2014-07-11 17:16:05.274 ValueTrackingSlider[4006:60b] 7: UIWindow
from asvaluetrackingslider.
Ok. Here is what I get:
2014-07-12 06:58:37.883 ValueTrackingSlider[2136:60b] 1: SliderCell
2014-07-12 06:58:37.884 ValueTrackingSlider[2136:60b] 2: UITableViewWrapperView
2014-07-12 06:58:37.885 ValueTrackingSlider[2136:60b] 3: UITableView
2014-07-12 06:58:37.886 ValueTrackingSlider[2136:60b] 4: UIViewControllerWrapperView
2014-07-12 06:58:37.886 ValueTrackingSlider[2136:60b] 5: UINavigationTransitionView
2014-07-12 06:58:37.888 ValueTrackingSlider[2136:60b] 6: UILayoutContainerView
2014-07-12 06:58:37.888 ValueTrackingSlider[2136:60b] 7: UIWindow
It is the same.
Could it be because my iPad is jailbroken and not updated to the latest iOS release?
from asvaluetrackingslider.
I have had exactly the same issue on iPad Air iOS 7.0.6 but now after upgrading it to 7.1.2 ASValueTrackingSlider is working fine again. The question is why does it not work on 7.0.6
from asvaluetrackingslider.
At least we have a workaround!
from asvaluetrackingslider.
Thanks @appicus,
Your input is most welcome and has saved me quite a bit of bewilderment! I have a vague recollection that in 7.0.6 the implementation of UITableViewCell changed temporarily - I think there might be a hidden container view that receives the message to super
and that's why the cell isn't brought to the front of the view hierarchy.
@pventura1976 could you just try the code below to see what results you get?
- (void)sliderWillDisplayPopUpView:(ASValueTrackingSlider *)slider;
{
NSLog(@"Before index:%d", (int)[self.superview.subviews indexOfObject:self]);
[self.superview bringSubviewToFront:self];
NSLog(@"After index:%d", (int)[self.superview.subviews indexOfObject:self]);
}
Here are the results I get:
2014-07-12 09:22:23.549 ValueTrackingSlider[14552:1381883] Before index:2
2014-07-12 09:22:23.551 ValueTrackingSlider[14552:1381883] After index:5
2014-07-12 09:22:26.605 ValueTrackingSlider[14552:1381883] Before index:1
2014-07-12 09:22:26.605 ValueTrackingSlider[14552:1381883] After index:5
There are 6 cells in the example tableview so the After index
should always be 5. If my conjecture is correct you should get a different result.
My guess is that this very dodgy code might work in 7.0.6. Whatever you do, don't actually use this code, as it will fail in all other iOS versions.
[self.superview.superview bringSubviewToFront:self];
Actually, that might need to be even dodgier:
[self.superview.superview bringSubviewToFront:self.superview];
from asvaluetrackingslider.
Here is the result, the same as your at "after index":
2014-07-12 13:58:53.564 ValueTrackingSlider[443:60b] Before index:3
2014-07-12 13:58:53.565 ValueTrackingSlider[443:60b] After index:5
2014-07-12 13:58:57.963 ValueTrackingSlider[443:60b] Before index:2
2014-07-12 13:58:57.964 ValueTrackingSlider[443:60b] After index:5
2014-07-12 13:59:00.580 ValueTrackingSlider[443:60b] Before index:3
2014-07-12 13:59:00.581 ValueTrackingSlider[443:60b] After index:5
2014-07-12 13:59:03.680 ValueTrackingSlider[443:60b] Before index:2
2014-07-12 13:59:03.681 ValueTrackingSlider[443:60b] After index:5
2014-07-12 13:59:07.996 ValueTrackingSlider[443:60b] Before index:1
2014-07-12 13:59:07.997 ValueTrackingSlider[443:60b] After index:5
None of these tricks worked:
[self.superview.superview bringSubviewToFront:self];
[self.superview.superview bringSubviewToFront:self.superview];
from asvaluetrackingslider.
Well now I am at a loss. If the table view cell is being brought to the front of the view hierarchy then the popup view shouldn't be obscured. Other than updating from 7.0.6, I'm not sure what to suggest. I don't have a device running 7.0.6, so I'm unable to investigate the cause. If you dig around in the view hierarchy you may discover the problem, but it's probably simpler to just update the iOS version on your device.
from asvaluetrackingslider.
It is not worth it. In my personal case, for now, I'll increase the height of the cell a bit.
from asvaluetrackingslider.
It can happen if you are calling [tableview reloadData] after changing slider value like I did.
So I haven`t found a way to dodge this and moved it from valueChanged to didFinishEditing
from asvaluetrackingslider.
Related Issues (20)
- slider
- Add "tap to slide' feature HOT 1
- Swift, PopUp is hidden by tableview cell. HOT 5
- left side of bar color looses color when cell is reused HOT 1
- Compiler warning on Xcode 8 GM + fix HOT 1
- The document “Main.storyboard” requires Xcode 8.0 or later. HOT 2
- Keep popup open HOT 2
- Feature request: vertical slider? HOT 1
- Slider over borders will show incomplete HOT 2
- Tap to Slide
- Accessibility Support
- Carthage support
- PopupView background color change
- Create Slider Programmatically
- range slider HOT 1
- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ASValueTrackingSlider name]: unrecognized selector sent to instance 0x10218d2a0' HOT 1
- Multiple line popup text implicit animations
- Difficult to slide the exact value HOT 1
- pop up doesnt show on swift project HOT 2
- Popup off center on min and max value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asvaluetrackingslider.