UISlider will not work when it becomes subordinate of UIView to other self.view

When I add my slider as a subview of any view except self.view, it does not work (does not slide), but it works fine when it is a self.view subheading. You can see this on views other than self.view, but this does not work.

Here is my code:

alphaSlider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 90, 10)];
    [alphaSlider setMinimumValue:0.01];
    [alphaSlider setMaximumValue:1];
    [alphaSlider setValue:0.5];
    [alphaSlider setUserInteractionEnabled:YES];
    [alphaSlider addTarget:self action:@selector(alphaSliderDidChange:) forControlEvents:UIControlEventValueChanged];
    alphaSlider.continuous = YES;
[submenu addSubview:alphaSlider];

Any way to fix this?

+5
source share
3 answers

Perhaps the submenu is not enabled for user interaction.

[submenu setUserInteractionEnabled:YES];

Another possibility is that the slider frame is outside the .frame submenu

clipToBounds UIViews NO, , , . , , . , .

[submenu setBackgroundColor:[UIColor blueColor]];

- (0, 0, 0, 0).

NSLog(@"%f, %f, %f, %f", submenu.frame.origin.x, submenu.frame.origin.y, submenu.frame.size.width, submenu.frame.size.height);

[submenu setClipsToBounds:YES];

, .

+9

, , . 10 pt, , .

iOS 8, .

UIView, UISlider, UISwitch UIPickerView, ​​ . , . , : " UISlider iPad/iPhone?", 0 .

, UISlider 0, .

+6

, , . , , , . 2 , .

-1

All Articles