0
我得到一个EXC_BAD_ACCESS。我已经尝试了所有关于访问不良的建议,但没有运气。我知道这是我设置UIImageView框架时造成的。设置UIImageView.frame会导致EXC_BAD_ACCESS偶尔
这是代码...
_backImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cardback_brothers_royal"]];
CGRect imageFrame = _backImageView.frame;
imageFrame.origin.x = -9;
imageFrame.origin.y = -9;
imageFrame.size.width = 151;
imageFrame.size.height = 225;
_backImageView.frame = imageFrame;
回溯:
0 0x33cf3a22 in -[UIView(CALayerDelegate) actionForLayer:forKey:]()
1 0x33aa201e in -[CALayer actionForKey:]()
2 0x33aa1fce in actionForKey(CALayer*, CA::Transaction*, NSString*)()
3 0x33aa1eba in CA::Layer::begin_change(CA::Transaction*, unsigned int, objc_object*&)()
4 0x33a9d9e6 in CA::Layer::set_position(CA::Vec2<double> const&, bool)()
5 0x33a9d8a2 in -[CALayer setPosition:]()
6 0x33a9d832 in -[CALayer setFrame:]()
7 0x33cf2aec in -[UIView(Geometry) setFrame:]()
8 0x33cf2814 in -[UIImageView _setViewGeometry:forMetric:]()
9 0x33cf2752 in -[UIImageView setFrame:]()
10 0x0006cd88 in -[CardView loadBack]
尝试调用图像的扩展名,例如:'[UIImage imageNamed:@“cardback_brothers_royal.png”]'或jpg,或其他。 – Malloc 2013-04-05 01:51:35
所有这些答案基本上都是以不同的方式来做同样的事情。你的问题不在于这个代码,而是在其他地方,可能是一个弱指针,它应该是强大的。你还需要为这段代码展示更多的上下文,它在哪里运行,什么时候它被称为等等。 – Rog 2013-04-05 02:38:39
hmmm ...僵尸在目标[UIView(CALayerDelegate)actionForLayer:forKey:],你有僵尸吗? – YvesLeBorg 2013-04-05 03:01:33