【问题标题】:Why does my view become white when i remove a subview?为什么当我删除子视图时我的视图变成白色?
【发布时间】:2011-06-07 09:41:55
【问题描述】:

在我看来,我有一个 scrollView 作为子视图。 scrollView 有另一个称为 PDFView 的子视图。它用于显示 PDF 页面。
此视图有 2 个子视图。 drawImage 是从磁盘加载的整个 PDF 视图上方的图像。
而paintView 是完成所有绘画和标记的第二个子视图。 但我只想在按下paint Button时添加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;
}

【问题讨论】:

    标签: iphone xcode uiview uiviewcontroller subview


    【解决方案1】:
    [thePDFView removeFromSuperview]; 
    

    删除滚动视图内的整个视图,只留下现在没有任何子视图的滚动视图。因此,您的视图是白色的。我想你只想删除 paintView.view 所以它应该是 [paintView.view removeFromSuperview];

    【讨论】:

      猜你喜欢
      • 2017-01-01
      • 1970-01-01
      • 2010-12-06
      • 2017-03-04
      • 2011-05-06
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      • 2016-02-01
      相关资源
      最近更新 更多