请有人告诉我如何在swift 2.2中使用sleep()几毫秒?
while (true){
print("sleep for 0.002 seconds.")
sleep(0.002) // not working
}
Run Code Online (Sandbox Code Playgroud)
但
while (true){
print("sleep for 2 seconds.")
sleep(2) // working
}
Run Code Online (Sandbox Code Playgroud)
这是工作.
我想以编程方式快速制作 UIProgressBar 吗?
这段代码有什么问题?
override func viewDidLoad() {
super.viewDidLoad()
let progressView = UIProgressView(progressViewStyle: .Bar)
progressView.center = self.view.center
progressView.frame = CGRectMake(0,0,50,20)
progressView.translatesAutoresizingMaskIntoConstraints = false
progressView.setProgress(0.5, animated: false)
self.view.addSubview(progressView)
}
Run Code Online (Sandbox Code Playgroud) 请有人告诉我,如何在 swift 2.2 中的 addtarget 函数中发送附加参数?\n示例:
\n\nbutton.addTarget(self, action: #selector(classname.myFunc(_:)), forControlEvents: UIControlEvents.TouchUpInside))\n\nfunc myFunc(sender:UIButton){\n print(\xe2\x80\x9ci am here\xe2\x80\x9c)\n}\nRun Code Online (Sandbox Code Playgroud)\n\n到
\n\nfunc myFunc(sender:UIButton,parameter:String){\n print(\xe2\x80\x9ci am here\xe2\x80\x9c)\n}\nRun Code Online (Sandbox Code Playgroud)\n 我在swift上制作iPhone应用程序,这里在ios swift应用程序中的一个viewDidLoad上多次调用ViewDidAppear和ViewWillAppear?
请帮我.
在我的快速应用程序中,当活动将转到后台时,我正在注销,但是当控制中心打开时,它将在后台运行.我的代码如下:
class MyApp:UIViewController{
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(appMovedToBackground), name: UIApplicationWillResignActiveNotification, object: nil)
func appMovedToBackground() {
print("App moved to background!")
self.logout()
}
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以在活动在后台运行时注销,但在控制中心打开时不会注销.