【发布时间】:2016-04-17 19:41:39
【问题描述】:
奇怪的事情发生在我身上,我有一个 uiviewcontroller,里面有一个 UIView,它有 2 个视图,以显示图形栏的错觉:
现在的事情是我第一次打开视图控制器没有任何反应,栏不会升高,切换到另一个视图然后回来后一切正常,栏会升高。 现在这里是关键,ViewDidLoad 和 ViewWillApper 使用相同的函数并通过断点和 println 所有数据到达 uiviewAnimation 以使条形上升,但没有任何反应,除非重新加载视图
发生了什么事?请照亮我
override func viewDidLoad() {
super.viewDidLoad()
TimeNow()
InsertNetoToCircul()
InsertSpendIntoCircul()
Checking()
AdvicesFunction()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
InsertNetoToCircul()
InsertSpendIntoCircul()
Checking()
AdvicesFunction()
}
func SpendBar(high : CGFloat,income:Float){
if high < 1{
OtzaotLabel.hidden = true
}
else{
OtzaotLabel.hidden = false
}
if income < 1{
LoLabel.hidden = true
}
else{
LoLabel.hidden = false
}
SpendBarView.frame.origin.x = 38
SpendBarView.frame.origin.y = 335
SpendBarView.frame.size.width = 70
// Calculate location in bar
//Spendings
var Mana:Int = (Int(high) / 500) * 30
var Sher:Float! = ((Float(high) % 500) / 500 ) * 30
if Rate{ Mana /= 2 }
UIView.animateWithDuration(0.4, animations: {
self.SpendBarView.frame.size.height = -CGFloat(Float(Mana) + Sher)
})
SpendBarView.backgroundColor = UIColor(red: 1.0, green: 0.4, blue: 0.4, alpha: 1)}
【问题讨论】: