Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISlider Disappeared in iOS 8.3

UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(50, 50, 100, 40)];
[self.view addSubview:slider];

The problem is that, I cannot view UISlider at all but I can still drag it. I have to guess the position and drag.

The compile environment is based on ios 6 sdk (mandatory because my app doesn't use flat yet) Does anybody know how to fix this? Thank you very much.

like image 958
SaKKo sama Avatar asked Nov 10 '22 15:11

SaKKo sama


1 Answers

I've also experienced this with an iOS 6.1 application running on iOS 8.3.

It appears that Apple have cleaned up the image resources which are for the old iOS appearance. I'm not sure if this was a mistake or intentional.

I found a solution to the issue using the methods provided to customise the appearance of the control which are detailed in the UISlider class reference.

Here's my code:

[self.myControl setThumbImage:[UIImage imageNamed:@"thumb.png"] forState:UIControlStateNormal];
[self.myControl setMaximumTrackImage:[UIImage imageNamed:@"background.png"] forState:UIControlStateNormal];
[self.myControl setMinimumTrackImage:[UIImage imageNamed:@"highlight.png"] forState:UIControlStateNormal];

I was able to re-create the standard appearance relatively easily.

I hope this helps.

like image 182
Adam Nierzad Avatar answered Dec 05 '22 07:12

Adam Nierzad