![](/img/trans.png)
[英]Ionic 3 IOS App does not work for first launch, but works after force kill and launch
[英]UIView Extension does not work on app first launch
我正在使用以下 UIView 擴展:
https://github.com/snoozelag/GoneVisible
我已成功下載該文件並添加了 Swift 文件,並且我正在使用該擴展程序在導航欄上隱藏(消失的方法)和顯示(可見的方法)按鈕。 當應用程序首次打開時,如果用戶已經登錄,我會調用此擴展程序以嘗試隱藏某些按鈕。但是,這並沒有奏效。 奇怪的是,在我轉到不同的視圖並返回后,它確實可以工作並隱藏按鈕。
這是代碼:
import UIKit
導入解析
類視圖控制器:UIViewController {
@IBOutlet weak var signUpButton: UIButton!
@IBOutlet weak var logInButton: UIButton!
@IBOutlet weak var myAccountButton: UIButton!
@IBOutlet weak var bigGame: UIImageView!
private func setUpPage(){
let currentUser = PFUser.current()
if currentUser != nil {
// Do stuff with the user
self.myAccountButton.visible()
self.signUpButton.gone()
self.logInButton.gone()
} else {
// Show the signup or login screen
self.myAccountButton.gone()
self.signUpButton.visible()
self.logInButton.visible()
}
}
override func viewDidLoad() {
setUpPage()
super.viewDidLoad()
self.navigationItem.hidesBackButton = true;
}
override func viewWillAppear(_
animated: Bool) {
setUpPage()
}
我的問題是,如何在第一次打開應用程序時觸發此擴展程序?
非常感謝你的幫助 :)
super.viewWillAppear(...)
。這可能會解決您的問題 - 但即使不是這樣做也是正確的。
更新:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.