博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Removing image from UIImageView
阅读量:6452 次
发布时间:2019-06-23

本文共 1210 字,大约阅读时间需要 4 分钟。

I load a UIImageView with an image depending on user interaction. When the parent view is initially displayed, no image has been selected and the imageview is black. If the user leaves that view and comes back, the image is still there. I've tried

myImageView.image = nil;

upon leaving the view but the image remains. How can I remove the image so the imageview appears black again?

The UIImageView is connected through IB.

 

 

 

Setting the UIImageView as:

myImageView.image = nil

is the correct way to clear an UIImageView. Are you loading the image when your calling function returns? Is your UIImageView being declared, and/or used elsewhere in your main function?

 

 

 

I also got the same problem, no matter I use myImageView.image = nil or [myImageView setImage:nil] the image still show on the UIImageView; assuming either one should works. It spend me many hours to debug and find out where have problem. Finally, I did it by using the following code,

        [UIView beginAnimations:nil context:nil];         [UIView animateWithDuration:1 animations:nil];         myImageView.image = nil;         [UIView commitAnimations];

I don't know why, but when I work as an animation then the image can be clear perfectly.

转载地址:http://pfgwo.baihongyu.com/

你可能感兴趣的文章
JQUERY AJAX请求
查看>>
html css 伪样式
查看>>
超级账本Fabric区块链用弹珠游戏Marbles 部署
查看>>
Maven多模块项目
查看>>
Oracle、PostgreSQL与Mysql数据写入性能对比
查看>>
整理Java基础知识--选择与判断
查看>>
Linux查看程序端口占用情况
查看>>
jar包冲突案例分析.md
查看>>
控制圈复杂度的9种重构技术总结
查看>>
当软件项目全部能靠自己搞定了,也能接几万元的软件项目时,未必适合创业...
查看>>
数据分析--数字找朋友
查看>>
推荐好用的开源库或软件
查看>>
18年selenium3+python3+unittest自动化测试教程(下)
查看>>
Redis集群中删除/修改节点(master、slave)(实验)
查看>>
memcache数据库和redis数据库的区别(理论)
查看>>
我的友情链接
查看>>
MyBatis+Spring结合
查看>>
shell实例-判断apache是否正常启动
查看>>
SharedPreferences存储复杂对象解决方案
查看>>
Office 365之SkyDrive Pro
查看>>