Ios 在“TouchesBegind:withEvent”中添加子视图在绘制之前有延迟
这是容器视图:Ios 在“TouchesBegind:withEvent”中添加子视图在绘制之前有延迟,ios,uiview,Ios,Uiview,这是容器视图: @implementation - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.tapView removeFromSuperview]; self.tapView = nil; self.tapView = [[UIView alloc] initWithFrame:CGRectInset(self.bounds, 10.0f, 10.0f)];
@implementation
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.tapView removeFromSuperview];
self.tapView = nil;
self.tapView = [[UIView alloc] initWithFrame:CGRectInset(self.bounds, 10.0f, 10.0f)];
self.tapView.backgroundColor = [UIColor redColor];
[self addSubview:self.tapView]; // Takes too much time before view shows up on screen
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self.tapView removeFromSuperview];
self.tapView = nil;
}
@end
我想了解为什么在将tapView添加为子视图和在屏幕上绘制之间会有延迟。虽然只有几毫秒,但很明显
我希望实现的最佳性能示例是在本机键盘上轻敲。点击一个键会显示一个新的视图,或者是它?马上。想好了!
容器视图位于启用了“延迟内容触摸”的滚动视图中