小编sul*_* qg的帖子

如何在swift 2.2中睡几毫秒?

请有人告诉我如何在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)

这是工作.

sleep uikit swift

42
推荐指数
3
解决办法
4万
查看次数

如何以编程方式快速制作 UIProgressBar

我想以编程方式快速制作 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)

uiviewcontroller uiprogressbar swift

7
推荐指数
1
解决办法
8341
查看次数

如何在addtarget函数中发送附加参数?

请有人告诉我,如何在 swift 2.2 中的 addtarget 函数中发送附加参数?\n示例:

\n\n
button.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}\n
Run Code Online (Sandbox Code Playgroud)\n\n

\n\n
func myFunc(sender:UIButton,parameter:String){\n    print(\xe2\x80\x9ci am here\xe2\x80\x9c)\n}\n
Run Code Online (Sandbox Code Playgroud)\n

uibutton ios swift

5
推荐指数
1
解决办法
8326
查看次数

在ios swift app中的一个viewDidLoad上多次调用ViewDidAppear和ViewWillAppear

我在swift上制作iPhone应用程序,这里在ios swift应用程序中的一个viewDidLoad上多次调用ViewDidAppear和ViewWillAppear?

请帮我.

viewdidload viewdidappear viewwillappear ios swift

1
推荐指数
1
解决办法
4774
查看次数

当控制中心打开时,为什么快速应用程序在后台运行?

在我的快速应用程序中,当活动将转到后台时,我正在注销,但是当控制中心打开时,它将在后台运行.我的代码如下:

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)

有什么方法可以在活动在后台运行时注销,但在控制中心打开时不会注销.

nsnotificationcenter ios swift

0
推荐指数
1
解决办法
708
查看次数