2012-09-05 50 views
1

我有分頁滾動型。我宣佈它:ContentOffset和返回頁首問題

if(_fullPosterScroll == nil) _fullPosterScroll = [[UIScrollView alloc] initWithFrame:rc]; 
    [_fullPosterScroll setDelegate:self]; 
    [_fullPosterScroll setBackgroundColor:[UIColor blackColor]]; 
    [_fullPosterScroll setCanCancelContentTouches:NO]; 
    _fullPosterScroll.indicatorStyle = UIScrollViewIndicatorStyleWhite; 
    _fullPosterScroll.clipsToBounds = NO; 
    _fullPosterScroll.pagingEnabled = YES; 
    _fullPosterScroll.alwaysBounceHorizontal = NO; 
    _fullPosterScroll.directionalLockEnabled = YES; 

和一個水龍頭後,我調用一個方法:

[_fullPosterScroll setContentOffset:CGPointMake(_selectedPosterPosition*(_fullPosterScroll.frame.size.width), 0) animated:YES]; 
NSLog(@"%f",_fullPosterScroll.contentOffset.y); 

爲什麼之後,在登錄我有例如225.00?!這應該是0!

回答

1

我看不出您發佈的代碼有什麼問題,但您應該檢查以確保setContentOffset不會觸發任何正在更改偏移量的委託方法。

另外,蘋果有一個示例項目,PageControl,這不正是你想要的,所以你應該看看,如果你想有一個完整的例子。

+0

謝謝,我叫上了。 – Kuba