[英]UIView setNeedsDisplay Has No Effect?
I have a UIView-derived view that is drawn only once and never updated . 我有一个UIView派生的视图,该视图仅绘制一次,并且从未更新 。
Calling [self setNeedsDisplay]
has no effect. 调用[self setNeedsDisplay]
无效。 What could cause this? 是什么原因造成的?
It doesn't matter whether the drawing code is in 绘图代码是否在其中都没关系
drawRect:
, or drawRect:
或 drawLayer:inContext:
(with an empty drawRect() defined) drawLayer:inContext:
定义了一个空的drawRect()) If drawLayer:inContext is not defined, then drawRect is called. 如果未定义drawLayer:inContext,则调用drawRect。 But just once (during layout). 但是只有一次(在布局期间)。
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx {
// drawing occurs, but just once (during view layout)
}
`- (void)drawRect:(CGRect) rect {
// empty -- never called
}
A small list of what I've tried: 我尝试过的一小部分:
因此,可以将其标记为已回答:确保在主线程上调用UIKit方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.