简体   繁体   English

UIButton setImage:forState不使用64位架构

[英]UIButton setImage: forState not working with 64 bit architecture

I have existing project created a year ago. 我有一年前创建的现有项目。 After AppStore's 64 bit requirement announcements, I had to include arm64 architecture into my project 在AppStore的64位需求公告之后,我不得不将arm64架构包含在我的项目中

But after adding arm64 into appTarget -> Build Settings -> Valid Architectures all the setImage: forState methods of all UIButton objects stopped working, while setBackGroundImage: forState is working normally. 但是在将arm64添加到appTarget -> Build Settings -> Valid Architectures ,所有UIButton对象的setImage: forState方法都停止工作,而setBackGroundImage: forState正常工作。

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 20, 20)];
[button setImage:image forState:UIControlStateNormal];

To test this oddity I created new project and created UIButton and used setImage: forState method, everything is working as expected. 为了测试这种奇怪,我创建了新项目并创建了UIButton并使用了setImage: forState方法,一切都按预期工作。

If I remove back arm64 architecture, every thing is ok with my project. 如果我删除了arm64架构,那么我的项目就可以了。 I don't know what I did wrong with my project. 我不知道我的项目做错了什么。

在此输入图像描述

你应该使用UIControlState tydef而不是int [1]

[button setImage:image forState:UIControlStateNormal]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM