我想运行一段代码,在第一次启动应用程序时将变量设置为true,然后将其设置为false,这样它就不会再次运行.简而言之,它应该在它的生命周期中只运行一次.我已经尝试了几乎所有的东西,包括dispatch_once_t但是对我来说不起作用.我把我的代码放在viewDidLoad,viewDidAppear等但是没有用.任何帮助表示赞赏,谢谢!
css 选择器 * + * 实际上是什么意思?当您执行检查元素时,您可以在谷歌浏览器的控制台中看到它。在我看来,这似乎是对 "Every second child" 应用一种风格,但仍然想确定。谁能帮我吗?
例子:
*+* {
margin-top:1em;
}
Run Code Online (Sandbox Code Playgroud) 到目前为止,我创建了自己的自定义视图,它是 UIView 类的子类:
class MyConnections: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// Drawing code
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 1)
CGContextSetStrokeColorWithColor(context, UIColor.blackColor().CGColor)
let circle = CGRectMake(5, 60, 80, 80)
CGContextAddEllipseInRect(context, circle)
CGContextStrokePath(context)
CGContextSetFillColorWithColor(context, UIColor.whiteColor().CGColor)
CGContextFillEllipseInRect(context, circle)
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的视图控制器,我将上面的视图添加为子视图:
let profile = MyConnections()
override func …Run Code Online (Sandbox Code Playgroud)