Comments (9)
截个图看看哪些成员变量导致了警告
from hzphotobrowser.
block里的成员变量都报了,block里写成员变量也是会引起循环引用的,出了问题还不好排查
from hzphotobrowser.
xcode版本能否告知?
from hzphotobrowser.
@chennyhuang 9.4
from hzphotobrowser.
理论上UIview的block不会造成循环引用:
首先循环引用发生的条件就是持有这个block的对象,被block里边加入的对象持有。当然是强引用。
所以UIView的动画block不会造成循环引用的原因就是,这是个类方法,当前控制器不可能强引用一个类,所以循环无法形成。
UIView中的block持有当前控制器,但是当前控制器中是没有持有UIView类的,没有形成循环.当动画结束时,UIView会结束持有这个block,如果没有别的对象持有block的话,block对象就会被释放掉,从而block会释放掉对self的持有,整个内存引用关系被解除.
from hzphotobrowser.
当 block 本身不被 self 持有,而被别的对象持有,同时不产生循环引用的时候,就不需要使用 weak self 了。最常见的代码就是 UIView 的动画代码,我们在使用 UIView 的 animateWithDuration:animations 方法 做动画的时候,并不需要使用 weak self,因为引用持有关系是:
UIView 的某个负责动画的对象持有了 block
block 持有了 self
因为 self 并不持有 block,所以就没有循环引用产生,因为就不需要使用 weak self 了。
from hzphotobrowser.
@chennyhuang 谢谢,学到了,请问作者,可以展示本地拿到的UIImage吗
from hzphotobrowser.
不支持本地,本地的自己写一个了,太简单
from hzphotobrowser.
去除Block中实例变量警告的方法:Building Settings ->搜索implicit retain of 'self' ,将对应的值改为NO
from hzphotobrowser.
Related Issues (20)
- 崩溃 HOT 3
- gif不会播放 HOT 2
- 我增加了可以删除某一张图片的方法,如有需要请回复 HOT 2
- 可以增加视频的类型吗 HOT 1
- 问题请教 HOT 1
- 👍,不过保存gif图片有问题,可以从SDImageCache取出gif图片data,进行存储 HOT 2
- 请教下,保存图片取不到图片data,直接报错 HOT 15
- 将demo中样式二的代码改为browser.currentImageIndex = 3;时,拖动手势第一次会失效,第二次才可以 HOT 3
- 开启后横屏展示有问题 HOT 2
- 没有适配sdwebimage5.0以上版本吗... HOT 1
- 你好, 我想请教个问题
- sdwebimage5.0版本不适配
- iOS 8.3支持吗
- 保存图片失败,找不到原因 HOT 1
- 可以增加一个是否允许保存图片的接口吗
- 某些图片消失时的动画不正常----具体表现为旋转变小 HOT 1
- 在iphone7 iOS13.3上面,消失动画瞬间黑屏约1秒
- sourecView是UICollectionview HOT 1
- 能加视频吗
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hzphotobrowser.