簡體   English   中英

將UIProgressView進度設置為0

[英]Setting UIProgressView progress to 0

我有一個UIProgressView,它運行2.5秒,但是有時,例如,如果該應用程序正在從多任務中恢復,則加載欄將開始運行一半。 每次打開時,如何將UIProgressView重置為0.0? 我可以在viewDidLoad中將其設置為0,然后啟動計時器並在viewDidAppear設置動畫。 我只需要知道如何將progressView設置為0。

您將其設置在viewWillAppear ,即從后台恢復時是否將其推入層次結構ro時,將在顯示視圖時調用它。

override func viewWillAppear() {
    super viewWillAppear();
    self.progressView.progress = 0.f;
}

您還可以使用UIApplicationDidBecomeActiveNotification

//inside init
NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateProgressBar", name: UIDeviceBatteryLevelDidChangeNotification, object: nil);

//on dealloc
NSNotificationCenter.defaultCenter().removeObserver(self);


//the update method
func updateProgressBar() {
    self.progressBar.progress = 0.f;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM