import Foundation
import UIKit
class SinglePlayer: UIViewController {
var timerCount = 0
@IBOutlet weak var timer: UILabel!
var timerVar = NSTimer()
var taps = 0
func isCounting() {
timerCount += 1
timer.text = "\(timerCount)"
if timerCount >= 10 {
timerVar.invalidate()
}
}
override func viewDidLoad() {
super.viewDidLoad()
timerVar = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "isCounting", userInfo: nil, repeats:true)
}
}
答案 0 :(得分:1)
您可以使用此功能
self.presentViewController(SinglePlayerGameOver, animated: true, completion: nil)
如果你有navigationController,那么
self.navigationController?.pushViewController(SinglePlayerGameOver, animated: true);
检查时间超过10
后输入此代码