我有一個定製的UISlider,它的軌道圖像有時會消失。它隨機發生,當它的父視圖控制器被推到可見(我從來沒有看到它實際上消失)。iOS - iPhone:UISlider跟蹤圖像隨機消失
這裏是我設置的UISlider代碼:
timeSlider = [[UISlider alloc] initWithFrame:CGRectMake(55, 8, 210, 23)];
timeSlider.backgroundColor = [UIColor clearColor];
UIImage *blutrackImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetrack" ofType:@"png"]];
UIImage *whitetrackImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"whitetrack" ofType:@"png"]];
//UIEdgeInsetsMake(top,left,bottom,right)
UIImage *stetchLeftTrack = [blutrackImg stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
UIImage *stetchRightTrack = [whitetrackImg stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
[timeSlider setThumbImage: [UIImage imageNamed:@"whiteslide2.png"] forState:UIControlStateNormal];
[timeSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[timeSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
timeSlider.continuous = NO;
[timeSlider addTarget:self action:@selector(trackTime:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:timeSlider];
我建立在iOS 5.0。有沒有人遇到過這樣的事情?
正如DreamTimeStudioZ下面提到的,主要問題在於智能檢查,而不是setValue。非常感謝發佈您的解決方案:) – user1122025 2012-09-11 19:24:59