问题
I have a UIViewController with a UIScrollView inside, all the content is displayed in the scrollview correctly, but for some reason I can't scroll thru it and all buttons are unresponsive.
UIScrollView *_scrollView;
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
_scrollView.pagingEnabled = YES;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.delegate = self;
_scrollView.backgroundColor = [UIColor redColor];
[self.view addSubview:_scrollView];
NSInteger yPos = 175;
for(Issue *issue in _dataModel.issues)
{
// Create some items and add them to the scrollview
[_scrollView addSubview:tmpItem.view];
yPos += 140;
}
_scrollView.contentSize = CGSizeMake(768, yPos + 50);
I set the contentSize correctly, I use the same technique in a different view and there it just works fine. Not sure if I'm missing something here.
回答1:
Do like this hope it will solve your issue.
scrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0,320, 460)];
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(320,600)];
[self.view addSubView:scrollView];
来源:https://stackoverflow.com/questions/12345479/uiscrollview-is-unresponsive