Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame of handles are not set on parent view viewWillAppear: #34

Open
ghost opened this issue Aug 11, 2014 · 11 comments
Open

Frame of handles are not set on parent view viewWillAppear: #34

ghost opened this issue Aug 11, 2014 · 11 comments

Comments

@ghost
Copy link

ghost commented Aug 11, 2014

Try this in demo without any changes in other places:

- (void) configureLabelSlider
{
    self.labelSlider.minimumValue = 10;
    self.labelSlider.maximumValue = 100;

    self.labelSlider.lowerValue = 10;
    self.labelSlider.upperValue = 100;

    self.labelSlider.minimumRange = 10;
}

You will see that lowerLabel stiil 0, etc... and you cannot update it till viewDidLoad, cause frames are set only in layout step.

@muZZkat
Copy link
Owner

muZZkat commented Aug 11, 2014

Hi,

The reason the lowerValue is not correct is actually todo with some range checking when setting the value. Try setting the upprtValue first then the lowerValue. Everything should work.

Although I am not totally sure how this is related to the subject of frame handles not set on superview?

@ghost ghost changed the title Frame of handles are not set on superview viewWillAppear: Frame of handles are not set on parent view viewWillAppear: Aug 11, 2014
@ghost
Copy link
Author

ghost commented Aug 11, 2014

lowerValue is correct, but if you will try to update frame of self.lowerLabel before parent view viewDidAppear, you will get that lowerCenter is {0;0}. I just want set up frames before my view appears on screen, but it impossible, cause you set frames of handles only in layoutSubview:

@muZZkat
Copy link
Owner

muZZkat commented Aug 11, 2014

OK, I understand now.

Not really sure what would be the correct way to this. Maybe the subviews can be setup in configureView, this seems to fix that particular bug.

@muZZkat
Copy link
Owner

muZZkat commented Aug 11, 2014

Otherwise, maybe lowerCenter/upperCenter should not be calculated from the handles subview, the current code actually uses _lowerHandle.center, this would be incorrect if the image used alignment insets....

@ghost
Copy link
Author

ghost commented Aug 11, 2014

May be you need make slider class more generic and add labels in it? I had no time to look more close on it, but if you want, later I can make PR.

@muZZkat
Copy link
Owner

muZZkat commented Aug 11, 2014

Yeah not really interested in adding labels to the control, its a very specific use case and could be require in a million different ways.

For now, just call [self.labelSlider layoutSubviews] at the start of the configureLabelSlider and it should work around your issue.

@pronebird
Copy link

I have the same issue.

@muZZkat you cannot call layoutSubviews directly, instead you should call setNeedsLayout, you can pump up layout update using layoutIfNeeded.

@muZZkat
Copy link
Owner

muZZkat commented Aug 21, 2014

@pronebird, I reworked the code a little so some of the initial frames get calculated in the init method. Haven't had time to push the final fix, I will try and get onto it tonight.

@pronebird
Copy link

@muZZkat thanks a lot. I think I will calculate centers manually for the time being, as it does not seem to be a big deal, although I admit, it can get handy. Thanks for such an awesome control!

@bliebman
Copy link

Hi @muZZkat, any headway on this issue? I am trying to load labels based on the location of the handles, and the handle center CGPoints are inaccurate until they are adjusted.

@robinmonjo
Copy link

any news on this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants