Why does my view become white when i remove a subview?
in my view I have a scrollView as subview. The scrollView has another subview called thePDFView. It is for showing a PDF page.
This view has 2 subviews. drawImage is an image loaded from disk above the whole PDF view. And paintView is the second subview where all the painting and markup is done. But I only want to add paintView when I press the paint Button. This works, but when I press it again to stop painting mode and re开发者_StackOverflow社区move the view from superview, the whole screen gets white. How can I bypass that?- (id)init
{
...
[self.view addSubview:theScrollView];
[theScrollView addSubview:thePDFView];
drawImage = [UIImage imageWithData:retrievedData];
[thePDFView addSubview:drawImage];
paintView = [[PaintViewController alloc] initWithImage:drawImage andPath:pageString];
}
- (void) togglePainting:(NSNotification *)notif {
if (!painting) {
theScrollView.scrollEnabled = false;
[thePDFView addSubview:paintView.view];
}
else {
theScrollView.scrollEnabled = true;
[thePDFView removeFromSuperview];
}
painting = !painting;
}
[thePDFView removeFromSuperview];
removes the whole view which was inside the scroll view leaving you nothing but the scrollview which does not have any subviews now. Hence your view is white. I think you wanted to remove only paintView.view
so it should be [paintView.view removeFromSuperview];
精彩评论