Ios 自定义UI切换拇指颜色和图案图像导致应用程序崩溃(ARC)
我想通过将图像设置为他的方法“setThumbTintColor”来定制我的UISwitch拇指,但这会导致应用程序崩溃。如果我简单地将颜色设置为:Ios 自定义UI切换拇指颜色和图案图像导致应用程序崩溃(ARC),ios,automatic-ref-counting,customization,uiswitch,Ios,Automatic Ref Counting,Customization,Uiswitch,我想通过将图像设置为他的方法“setThumbTintColor”来定制我的UISwitch拇指,但这会导致应用程序崩溃。如果我简单地将颜色设置为: [switch setThumbTintColor:[UIColor blackColor]]; @property (nonatomic,strong) UIImage *imageThumb; @property (nonatomic,strong) UIColor *colorImageThumb; ...
[switch setThumbTintColor:[UIColor blackColor]];
@property (nonatomic,strong) UIImage *imageThumb;
@property (nonatomic,strong) UIColor *colorImageThumb;
...
imageThumb = [UIImage imageNamed:@"myThumbImage.png"];
colorImageThumb = [UIColor colorWithPatternImage:imageThumb];
[switch setThumbTintColor:colorImageThumb];
没问题
但如果我想添加这样的图像:
[switch setThumbTintColor:[UIColor blackColor]];
@property (nonatomic,strong) UIImage *imageThumb;
@property (nonatomic,strong) UIColor *colorImageThumb;
...
imageThumb = [UIImage imageNamed:@"myThumbImage.png"];
colorImageThumb = [UIColor colorWithPatternImage:imageThumb];
[switch setThumbTintColor:colorImageThumb];
UISwitch解除锁定后,应用程序立即崩溃(我正在使用ARC,但这是错误消息)
这个线程似乎解决了问题,但没有弧的方式
有什么想法吗
[编辑] 图像名称为thumb_wood.png 该错误消息是一条“EXC\u坏访问”错误消息 主线程树中的最后一个方法是: 0 objc_msgSend 4-[UISwitch dealloc] 5-[MyUIViewController.cxx_destruct]
等等。。。销毁链你的图像名是什么?您看到的确切错误是什么?你想加载什么类型的图像?我已经编辑了我的问题来回答你。你是否在代码中正确设置了图像文件名?它是否位于可从您的代码访问的目录中?我刚刚删除了一个文件,并正确地重新添加了图像,以确保应用程序仍在崩溃。是,该文件夹可访问。@我正在使用ARC