我在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;
}
答案 0 :(得分:0)
可能的问题:
3.它实际上是滚动但不可见,因此为了测试目的,启用了以下内容 -
toolsScrollView.showsVerticalScrollIndicator = YES;
toolsScrollView.showsHorizontalScrollIndicator = YES;