【发布时间】:2015-05-28 07:24:43
【问题描述】:
我将UIScrollView 放在CollectionViewCell 上,但scrollview 无法滚动
#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 链接到 XIB 中的 UIScrollView
滚动视图不能滚动,函数scrollViewDidScroll永远不会被触发
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
return;
}
【问题讨论】:
-
collectionView 不会从 scrollView 窃取触摸事件吗?
-
UICollectionViewCell 是 UIView 的子类
-
你的collectionView中有相关代码吗?
标签: ios iphone uiscrollview uicollectionview