为什么当我删除子视图时我的视图会变成白色?
在我看来,我有一个滚动视图作为子视图。滚动视图有另一个子视图,称为 PDFView。它用于显示 PDF 页面。
该视图有 2 个子视图。 drawImage 是从磁盘加载到整个 PDF 视图上方的图像。
PaintView 是第二个子视图,所有绘画和标记都在其中完成。 但我只想在按下绘画按钮时添加paintView。
这有效,但是当我再次按下它以停止绘画模式并从超级视图中删除视图时,整个屏幕会变白。
我怎样才能绕过它?
- (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;
}
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 remove 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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除滚动视图内的整个视图,只留下现在没有任何子视图的滚动视图。因此你的观点是白色的。我认为您只想删除
paintView.view
所以它应该是[paintView.view 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];