UIScrollView is unresponsive

南楼画角 提交于 2019-12-12 04:09:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!