After a UIView is tapped, I hide it and initialize new object with UIView and Quartz drawRect.
- (void)viewTapped:(UITapGestureRecognizer *)recognizer {
self.vignetteView.hidden=true;
lupeItself = [[LoupeView alloc] initWithView:_pageView setZoomImageName:_zoomPageImageName setDelegate:self];
}
Code above is hiding the UImageView only after some 2 seconds delay. But if last line (LoupeView alloc etc.) is removed, the it is hided instantly. Why? How to make the view hide instantly?
The .hidden = true change will not become visible until the execution path returns to the main runloop. The second line is probably blocking for a few seconds, preventing these changes from occuring (or drawRect is taking a long time further down the pipeline).
The simplest fix would be to defer the second line until the next runloop iteration:
self.vignetteView.hidden = YES;
// defer execution so the above changes are immediately visible
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
lupeItself = [[LoupeView alloc] initWithView:_pageView setZoomImageName:_zoomPageImageName setDelegate:self];
}];
Also, a minor point: you should use the constants YES and NO for BOOL properties and arguments, instead of true and false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With