问题描述
我已经创建了视图xib并以ViewController
的扩展名调用它。我创建的Xib只是显示消息,并且如果出现Internet断开xib消息,则在每个ViewController
上调用它。
我面临的问题-如何从超级视图中删除xib?我正在打电话并显示我的xib,但是当我尝试删除它时却没有。
我需要remove Xib on netcheck = true.
在每个ViewController中调用代码:
override func viewDidLoad() {
if netcheck == false {
showNotificationView()
}
}
扩展代码:
extension UIViewController {
func showNotificationView() {
let viewW = offlineView.fromNib()
view.addSubview(viewW)
viewW.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
viewW.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor),viewW.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor),viewW.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor,constant: -25),viewW.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor),])
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)