相关疑难解决方法(0)

将现有CGColor分配给CGColor属性适用于iOS模拟器,而不是iOS设备.为什么?

我知道如何解决我即将概述的问题,但是,我有点困惑的是为什么代码方案在iOS模拟器中工作但在我的iPad上不起作用.

我有一个检查各种属性的方法,然后CALayer根据属性的状态设置a的背景颜色.以下代码与我的颜色分配方法类似:

//This will be the CALayer BGColor...
CGColor c = UIColor.blueColor.CGColor; //Blue is the default
switch (myState)
{
    case state_one:
        c = UIColor.greenColor.CGColor;
        //... more code ...
        break;
    case state_two:
        c = UIColor.redColor.CGColor;
        //... more code ...
        break;
    case state_three: //multiple cases are like the state_three case.
        //Other code, but I don't need to assign the color.  Blue works...
}

myCALayer.backgroundColor = c; //Oh-noes!!! Here we get the dreaded EXC_BAD_ACCESS on iPad
//...more code dealing with the …
Run Code Online (Sandbox Code Playgroud)

exc-bad-access objective-c ipad ios ios-simulator

8
推荐指数
2
解决办法
9239
查看次数

标签 统计

exc-bad-access ×1

ios ×1

ios-simulator ×1

ipad ×1

objective-c ×1