2011-08-03 5 views
0

ネストされたUIScrollViewを使用してカスタムUIViewを実装しています。コントローラにUIScrollViewが下にのみスクロールする

- (id)initWithFrame:(CGRect)frame { 
    self = [super initWithFrame:frame]; 
    if (self) { 
     scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 10, 252, 200)];   
     scrollView.backgroundColor = [UIColor clearColor]; 
     scrollView.contentSize = CGSizeMake(500, 400); 
     scrollView.userInteractionEnabled = YES; 
     scrollView.pagingEnabled = NO; 
     scrollView.scrollEnabled = YES; 
     scrollView.clipsToBounds = YES; 
     [scrollView setAutoresizesSubviews:YES]; 
     [scrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; 
     [scrollView setDirectionalLockEnabled:NO]; 
     [scrollView setDelegate:self]; 

     [scrollView setShowsHorizontalScrollIndicator:YES]; 
     [scrollView setShowsVerticalScrollIndicator:YES]; 
     [scrollView setBounces:YES]; 
     [scrollView setAlwaysBounceHorizontal:NO]; 
     [scrollView setAlwaysBounceVertical:NO]; 
     [scrollView setBouncesZoom:YES]; 
     [scrollView setDelaysContentTouches:YES]; 
     [scrollView setCanCancelContentTouches:YES]; 

     [scrollView setMaximumZoomScale:1]; 
     [scrollView setMinimumZoomScale:1]; 
     [scrollView setOpaque:YES]; 

     [self addSubview:scrollView];        
    } 
    return self; 
} 

初期設定は次のようになります

CustomView *customView = [[CustomView alloc] initWithFrame:CGRectMake(0, 100, 320, 200)]; 
[self.view addSubview:cut]; 

問題:(私は指を下にドラッグしたとき)、私は左をスクロールしようとすると、右、だけアップ方向にビューのスクロールをスクロールまたは何も行動していない

私は間違って何をしていますか?

答えて

0

設定する多くのプロパティは、デフォルト値と同じです。ここでデフォルト値を見つけるでしょう:UIScrollView Class Reference

私は、すでにデフォルト値を持っているプロパティーを削除することをお勧めします。特にスクロールのプロパティ。

[scrollView setShowsHorizontalScrollIndicator:YES]; 
[scrollView setShowsVerticalScrollIndicator:YES]; 
[scrollView setBounces:YES]; 
[scrollView setAlwaysBounceHorizontal:NO]; 
[scrollView setAlwaysBounceVertical:NO]; 
[scrollView setBouncesZoom:YES]; 
[scrollView setDelaysContentTouches:YES]; 
[scrollView setCanCancelContentTouches:YES]; 
+0

最初のinitは次のようでした:scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10、10、252、200)]; scrollView.backgroundColor = [UIColor clearColor]; scrollView.contentSize = CGSizeMake(500,400); scrollView.userInteractionEnabled = YES; scrollView.pagingEnabled = NO; scrollView.scrollEnabled = YES; と同じ動作でした – unkm

関連する問題