当ipad从横向改为纵向时,ios7 UIProgressView丢失

当ipad从横向改为纵向时,ios7 UIProgressView丢失,ios7,uiprogressview,Ios7,Uiprogressview,我使用UIProgressView来做音乐播放进度条,它在ios6或之前的版本中使用得很好,但在ios7中有一个问题。它不见了!当我将ipad从横向旋转到纵向时 下面的代码 [_playerBar setMiddleTrackImage:[IMG(@"player_progress_loading") resizableImageWithCapInsets:UIEdgeInsetsMake(4, 3, 5, 4)]]; [_playerBar setMaximumTrackIma

我使用UIProgressView来做音乐播放进度条,它在ios6或之前的版本中使用得很好,但在ios7中有一个问题。它不见了!当我将ipad从横向旋转到纵向时

下面的代码

    [_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];

感谢您的帮助

我认为缺少UIprogressView是因为UIprogressView高度等于0。当旋转到纵向时,可调整大小的带capinsets的图像:UIEdgeInsetsMake()和autoresizingMask会更改高度

你可以用

_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth
并调整高度