Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同个对象调用removeBadgeViewt后 再次调用 yee_MakeBadgeText 失效 #1

Open
zschhx opened this issue Apr 11, 2018 · 2 comments

Comments

@zschhx
Copy link

zschhx commented Apr 11, 2018

在removeBadgeView中只是 removeFromSuperview而没有取消对象关联属性
导致[self yee_BadgeLable]==nil 无法触发 也无法再次触发addSubview 方法就无法第二次调用 yee_MakeBadgeText方法
建议在 removeBadgeView方法中添加对象去除关联方法
objc_removeAssociatedObjects(self)

@Mr-yuwei
Copy link
Owner

谢谢,之前写没有考虑这么多,现在已经更新为1.0.2,之前的版本因为使用了masksToBounds部分属性会造成离屏渲染问题,1.0.1方法已经被舍弃,你看看BadgeViewDemo已经通过隐藏来实现,而不是移除。实际上到底是移除还是隐藏,这个都不是好的方法 1.如果对象只使用一次 ,如果不移除就会浪费内存空间2.如果多次使用,重复创建也会浪费内存, 我最后选择隐藏的方式.

@Mr-yuwei Mr-yuwei reopened this Apr 16, 2018
@colaxp
Copy link

colaxp commented Jan 11, 2019

if (![self.subviews containsObject:[self yee_BadgeLable]]) {
    [self addSubview:[self yee_BadgeLable]];
}

加了这句判断没问题了,最新的版本我更新不下来不知道怎么解决的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants