2015-05-28 65 views
0

我把一個UIScrollViewCollectionViewCellscrollview不能滾動放的UIScrollView上CollectionViewCell但滾動視圖不能滾動

#import <UIKit/UIKit.h> 


@interface MyCollectionViewCell : UICollectionViewCell<UIScrollViewDelegate>{ 

    IBOutlet UIScrollView *toolsScrollView; 


} 


@end 

@implementation MyCollectionViewCell 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     // Initialization code 
     //wangzheng 
     self = [super initWithFrame:frame]; 
     if (self) { 
      NSArray *nibView = [[NSBundle mainBundle] loadNibNamed:@"MyCollectionViewCell"owner:self options:nil]; 
      UIView *bw = [nibView objectAtIndex:0] ; 
      [self.contentView addSubview:bw]; 
      toolsScrollView.delegate=self; 


      UIView *toolView1 = [[UIView alloc] init]; 
      toolView1.backgroundColor = [UIColor blackColor]; 
      toolView1.frame = CGRectMake(300, 0, 80, 150); 
      [toolsScrollView addSubview:toolView1]; 


      toolsScrollView.delegate=self; 
      [toolsScrollView setContentSize:CGSizeMake(400 * 2, toolsScrollView.frame.size.height)]; 
      toolsScrollView.showsVerticalScrollIndicator = NO; 
      toolsScrollView.showsHorizontalScrollIndicator = NO; 
      toolsScrollView.delegate = self; 
      toolsScrollView.userInteractionEnabled=true; 
      toolsScrollView.scrollEnabled=true; 
     } 
     return self; 
    } 
    return self; 
} 

IBOutlet UIScrollView *toolsScrollView鏈接到UIScrollView在廈門國際銀行

enter image description here

滾動視圖不能滾動並且功能scrollViewDidScroll從不被觸發

- (void)scrollViewDidScroll:(UIScrollView *)scrollView 
{ 
    return; 

} 
+0

會不偷的CollectionView從滾動視圖的觸摸事件? – Zhang

+0

UICollectionViewCell是UIView的子類 – arachide

+0

在你的collectionView中有相關的代碼嗎? – Bannings

回答

0

可能的問題:

  1. toolsScrollView變量未連接,並且不指向有效的滾動視圖或,
  2. 的toolsScrollView的幀不是從筆尖加載後正確的。或者,

3.It的實際滾動,但不可見的,所以啓用測試目的如下 -

toolsScrollView.showsVerticalScrollIndicator = YES; 
toolsScrollView.showsHorizontalScrollIndicator = YES;