سؤال

I use UIProgressView to do the music Playback progress bar ,It use well in ios6 or before,but there is a problem in ios7. It is missing!when I rotate the ipad from Landscape to Portrait.

the code below

    [_playerBar setMiddleTrackImage:[IMG(@"player_progress_loading") resizableImageWithCapInsets:UIEdgeInsetsMake(4, 3, 5, 4)]];
    [_playerBar setMaximumTrackImage:[IMG(@"player_progress") resizableImageWithCapInsets:UIEdgeInsetsMake(4, 3, 5, 4)]];

- (void)setMiddleTrackImage:(UIImage *)middleTrackImage {
    [_progressView setProgressImage:middleTrackImage];
} 

- (void)setMaximumTrackImage:(UIImage *)maximumTrackImage {
    [_progressView setTrackImage:maximumTrackImage];
}

_progressView = [[UIProgressView alloc] initWithFrame:rect];
[_progressView setProgressViewStyle:UIProgressViewStyleBar];
_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_progressView.center = CGPointMake(_slider.center.x, _slider.center.y+1);
_progressView.userInteractionEnabled = NO;

[_slider addSubview:_progressView];

_progressView.progressTintColor = [UIColor darkGrayColor];
_progressView.trackTintColor = [UIColor lightGrayColor];

any help is appreciated!

هل كانت مفيدة؟

المحلول

I think the UIprogressView missing is because the UIProgressView height is equal 0.when you rotate to Portrait,the resizableImageWithCapInsets:UIEdgeInsetsMake() and autoresizingMask change the height

you could use

_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth

and resize the height

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top