ios - 将 subview 添加到 UIViewController 使 UITablview subview 消失

标签 ios swift uitableview

此代码在以编程方式调用的函数内部调用。它插入的 UITableView 已放入 Storyboard中的 UIViewController 中。 UIViewController 嵌入在navigationController 中。

let containerView = UIView()
    containerView.frame.size.width = self.view.frame.width / 2
    containerView.frame.size.height = self.view.frame.width / 2
    let blurEffect = UIBlurEffect(style: .Dark)
    let blurEffectView = UIVisualEffectView(effect: blurEffect)
    blurEffectView.frame = containerView.bounds
    containerView.center = self.view.center
    containerView.addSubview(blurEffectView)
    self.view.insertSubview(containerView, aboveSubview: matchTableView)
    indicator?.startAnimation()

我只是想在表格 View 上添加一个事件指示器。实际事件指示器显示得很好,但我需要在其后面放置背景,以便可以正确看到它。一旦将任何类型的 subview 添加到 UIViewController 中,表格就会消失。

最佳答案

你尝试过吗:

let containerView = UIView()
...
containerView.opaque = false
containerView.backgroundColor = UIColor.clearColor()

关于ios - 将 subview 添加到 UIViewController 使 UITablview subview 消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34388455/

相关文章:

ios - com.esri.arcgis.runtime.error Code=10018 词法转换错误

Swift 显示图像 UIImageview

ios - 访问前一个 viewController 元素及其标签

ios - 如何将日期/时间字符串转换为不同的日期字符串?

swift - 在/Users/Shared/- 使用 Swift 创建一个目录

ios - 在 TableView 中显示之前过滤数组结果

ios - PFQueryTableViewController 不加载图像 parse.com

ios - 我应该如何重构我的自定义 UITableView 以提高可维护性

ios - Swift 通过引用传递结构?

iphone - NSInternalInconsistencyException 未捕获的异常 'NSInternalInconsistencyException',原因 : 'Could not load NIB in bundle: NSBundle with name