UIScrollView不适用于EXC_BAD_ACCESS [英] UIScrollView does not work with EXC_BAD_ACCESS

查看:111
本文介绍了UIScrollView不适用于EXC_BAD_ACCESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动视图,它是视图的子视图,并且具有子视图.问题是这样的:scrollView带有黑色背景(因为我已将其设置为透明),因此也不起作用. scrollView与IBOutlet连接.我重装了XIB 2次,需要修复什么?当我将scrollView添加为视图的子视图时:

I have a scrollview that is subview of view, and has the subviews. The problem is this: the scrollView came with the black background (as I have set transparent) and also does not work. The scrollView is connected with an IBOutlet. I redid the XIB 2 times, what needs fixing? When I add the scrollView as subview of view:

 [self.view addSubview:self.scrollView];

我在运行时遇到此错误:

I get this error during runtime:

   0x132b61:  calll  0x132b66;   CA::Layer::ensure_transaction_recursively(CA::Transaction*) + 14
   EXC_BAD_ACCESS(code=2 address=0xbf7ffffc)

如果我没有在代码中将其添加为子视图,则视图控制器将打开,并且滚动视图为黑色,并且不会滚动.

If I do not add it as a subview in the code, the view controller opens and the scrollview is black and does not scroll.

推荐答案

检查是否使用带有框架的scrollView进行了初始化:

Check if you init with your scrollView with frame:

self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 280, 360)];

还请记住将contentSize设置为大于框架,例如:

Remember also to set contentSize bigger than frame, for example:

self.scrollView.contentSize = CGSizeMake(2*280, 360);

还可以在您的界面中添加委托:

Also add delegate in your interface:

<UIScrollViewDelegate>

并委派它:

self.scrollView.delegate = self;

这篇关于UIScrollView不适用于EXC_BAD_ACCESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆