Tôi mới đến lập trình nhanh và ios nói chung. Tôi đang cố gắng hiển thị chế độ xem phương thức khi ứng dụng của tôi tải lần đầu tiên. Vấn đề tôi đang gặp phải là phương thức của tôi liên tục xuất hiện lặp đi lặp lại. Không chắc tôi sẽ sai đâu.trình bày một phương thức trong viewdidappear với swift
CÂU HỎI THƯỜNG GẶP: Cuối cùng tôi muốn điều này chỉ xảy ra khi người dùng mở ứng dụng lần đầu tiên.
class ViewController: UIViewController {
var introModalDidDisplay = false
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
showIntroModal()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func showIntroModal() {
if (!introModalDidDisplay) {
println(introModalDidDisplay)
introModalDidDisplay = true
let intro = self.storyboard?.instantiateViewControllerWithIdentifier("introModal") as IntroModalViewController
intro.modalPresentationStyle = UIModalPresentationStyle.FormSheet
self.presentViewController(intro, animated: true, completion: nil)
}
}
}
bạn chỉ cần xác định khi ghi đè func viewDidLoad() { super.viewDidLoad() showIntroModal()} –