旋转时消失UIScrollView的指示灯

时间:2012-03-07 15:45:11

标签: iphone uiscrollview rotation

滚动视图有两个问题。

(1) 旋转滚动视图后,滚动视图的指示消失。 我在旋转时调用setFrame,setContentSize和setContentOffset。 滚动视图上有很多子视图,因此内容大小不小。 旋转时我的所有桌面视图都很好。

(2) 我的应用可以恢复用户的阅读位置。 所以我将滚动视图的contentOffset存储为CGPoint。 如果我调用setContentOffset来恢复contentOffset,则scrollview的指示符会消失。 但是当视图出现时,如果contentOffset值设置为(0.0,0.0),则scrollview的指示符不会消失。 我尝试使用scrollRectToVisible:animated:,结果是一样的。

今天我在这些问题上花了10多个小时。帮助我〜请。

//创建

的部分
UIScrollView *scrollViewBoard = [ [ UIScrollView alloc ] initWithFrame: CGRectZero ];
[ scrollViewBoard setShowsHorizontalScrollIndicator: NO ];
[ scrollViewBoard setAlwaysBounceVertical: YES ];
[ scrollViewBoard setDelegate: self ];
[ self addSubview: scrollViewBoard ];
_board = scrollViewBoard;
[ scrollViewBoard release ];

//旋转的部分

- ( void ) adjustLayout: ( UIInterfaceOrientation )anOrientation {

MyTrackLog();
switch ( anOrientation ) {
    case UIInterfaceOrientationPortrait:
    case UIInterfaceOrientationPortraitUpsideDown: {
        [ _board setFrame: RECT_PORTRAIT_BOARD ];
    } break;
    case UIInterfaceOrientationLandscapeLeft:
    case UIInterfaceOrientationLandscapeRight: {
        [ _board setFrame: RECT_LANDSCAPE_BOARD ];
    } break;
    default:
        break;
}
[ _board setContentSize: [ self calculateContentSize: anOrientation ] ];
[ _board setContentOffset: _contentOffset ];
[ self arrangeAchievementButtons: anOrientation ];

} // adjustLayout:

谢谢。

2 个答案:

答案 0 :(得分:0)

[_board flashScrollIndicators];

进行方向更改后。

答案 1 :(得分:0)

也许UIScrollView扩展了显示。
你可以尝试:

UIScrollView的超级视图应将autoResizeSubViews设置为YESUIScrollView应将autoResizingMask设置为UIViewAutoResizingFlexibleWidth | UIViewAutoResizingFlexibleHeight 在方向更改后不要使用setFrame来调整大小

相关问题