小编iDe*_*Dec的帖子

应用和扩展程序之间的共享UserDefaults无法正常工作

所以我一直在环顾四周,并按照所有步骤正确设置共享UserDefaults,但我应该遗漏一些东西.

我在我的应用和扩展程序上激活了应用组功能.两者都使用相同的套件名称("group.TestSharedPreferences"),我这样写:

struct Preferences {
    static let shared = UserDefaults(suiteName: "group.TestSharedPreferences")!
}
Run Code Online (Sandbox Code Playgroud)

viewDidLoad:

Preferences.shared.set(1, forKey: "INT")
Run Code Online (Sandbox Code Playgroud)

阅读:

Preferences.shared.integer(forKey: "INT") // Returns 1 in Container App
Preferences.shared.integer(forKey: "INT") // Returns 0 in Today Extension
Run Code Online (Sandbox Code Playgroud)

即使synchronize()在设置后使用"INT",扩展中检索的值也不是容器App中保存的值.关于我可能遗失的任何想法?谢谢!

nsuserdefaults ios swift

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

如何在 Bootstrap 中自动调整行高?

我正在学习 Bootstrap,我试图弄清楚如何在这种情况下自动调整行高:

  • 容器流体中有 3 行
  • row1必须调整到其内容的高度
  • row3必须调整到其内容的高度并位于视口的底部
  • row2应将其高度调整为row1row3之间的空间以填充容器流体

html, body, .container-fluid {
  height: 100%;
  background: lightyellow;
}

.col {
  border: solid 1px #6c757d;
}

.content-1 {
  height: 50px;
  background-color: lightcoral;
}

.content-2 {
  height: 200px;
    background-color: lightgreen;
}

.content-3 {
  height: 25px;
  background-color: lightblue;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container-fluid">
  <div class="row">
    <div class="col">
      <div class="content-1">
      ROW 1 -> Height of its content
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <div class="content-2">
      ROW 2 …
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap bootstrap-4

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

以编程方式获取uibutton的约束

我在Storyboard中有4个按钮,包括BottomSpace和Horizo​​ntal Alignment约束.有没有办法访问这些约束常量而不将它们作为出口链接?我想在用户按下按钮时更新这些常量,因此伪代码的理想情况是:

func buttonPressed(_ button: UIButton) {
      button.bottomSpaceConstraint.constant += 10
      button.horizontalAlignment.constant += 10
}
Run Code Online (Sandbox Code Playgroud)

先感谢您!

ios nslayoutconstraint swift

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