在xib中使用<!doctype html>
<html class="no-js" lang="">
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript" charset="utf-8">
var Clicked = false;
function james() {
if(Clicked === false){
alert("james");
}
Clicked=true;
}
</script>
</head>
<body>
<div data-role="page" id="pagetwo" >
<a href="#pageone" onClick="james(); this.onClick=null;">Go to Page two</a>
</div>
<div data-role="page" id="pageone">
<a href="#pagetwo">Go to Page one</a>
</div>
</body>
</html>
,隐藏并显示子视图问题
我的<?php
require 'vendor/getID3/getid3/getid3.php';
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze('some mp3 file.mp3');
print_r($ThisFileInfo);
中有两个子视图,一个子视图是隐藏的,B子视图是未隐藏的,A在B的顶部;将A的状态设置为显示,但是A被B覆盖了。
仅在Xcode10.1和ios12.0 ++中出现。
答案 0 :(得分:1)
我想知道为什么它只发生在你身上.. !!但是,我尝试了与您在问题中指定的方法相同的方法,并完美地获得了结果。
代码:
override func viewDidLoad() {
super.viewDidLoad()
let myStackView = UIStackView()
myStackView.axis = .vertical
myStackView.alignment = .center
myStackView.distribution = .fillEqually
myStackView.spacing = 8
view.addSubview(myStackView)
let redView = UIView()
redView.backgroundColor = UIColor.red
redView.widthAnchor.constraint(equalToConstant: 125.0).isActive = true
redView.heightAnchor.constraint(equalToConstant: 50).isActive = true
let greenView = UIView()
greenView.backgroundColor = UIColor.green
greenView.widthAnchor.constraint(equalToConstant: 125.0).isActive = true
greenView.heightAnchor.constraint(equalToConstant: 50).isActive = true
myStackView.addArrangedSubview(redView)
myStackView.addArrangedSubview(greenView)
myStackView.translatesAutoresizingMaskIntoConstraints = false
myStackView.centerXAnchor.constraint(equalTo: view.centerXAnchor, constant: 0.0).isActive = true
myStackView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0.0).isActive = true
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
redView.isHidden = true
}
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
redView.isHidden = false
}
}
屏幕截图:
在viewDidLoad
和viewDidLoad
的 4秒之后
viewDidLoad
的 2秒之后
答案 1 :(得分:0)
我找到了原因,因为当heightLayoutConstraint的常量属性从0更改为实际高度100时,A视图的高度约束无效。所有这些都在主线程中完成。
UICollectionReusableView *customView;//Xib init
NSLayoutConstraint *customHeightConstraint;
//change constant
customHeightConstraint.constant = height;
[customView updateConstraints];
但是我查看了调试视图层次结构中的效果和属性,发现customView仍然是初始值0。