我在水平纸上有两个标签UIStackView。标签1是大字体(警报时间),标签2是小字体(AM / PM指示器),我想对齐每个标签的底部。
我已将堆栈视图的对齐方式设置为“底部”,但似乎只是对齐标签总面积的底部而不是实际文本的底部。结果是较小字体的底边比大标签底边高约3或4个像素。我该如何解决?
这是我List使用 SwiftUI为我的项目中的项目编写的代码。
struct ServicesListItem: View {
var title: String
var description: String
var colorHex: String
var imageName: String
var body: some View {
HStack {
Image(imageName)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 50, height: 50)
VStack(alignment: .leading, spacing: 4) {
Text(title)
.font(.system(size: 14, weight: .black, design: .rounded))
.foregroundColor(Color(hex: colorHex))
Text(description)
.font(.system(size: 10, weight: .medium, design: .rounded))
.foregroundColor(Color.gray)
}
.frame(height: 60)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想将每个元素的所有元素ServicesListItem放在另一个“视图”中,并在所有侧面添加填充,以使每个项目的内容看起来都在凸起的视图中,而不是List. 通过使用 UIView 作为 UITableViewCell 内的父视图,我使用 UIKit 轻松完成了这项工作。尚未找到使用 SwiftUI 执行此操作的方法。是否可以?
UIButton在将数据保存到数据库之前,我想使用两个s将A / B值设置为变量。我希望一个按钮在被点击时被选中,而在另一个按钮被点击时被取消选择,反之亦然。通过编程或在Interface Builder中完成此操作的最佳解决方案是什么?
I am trying to animate a button from outside the visible bounds of my UIViewController to the center of it. I have a constraint setup in my storyboard called myButtonLeading which I remove as part of my animation, and then I want to add a new constraint called newCenterConstraint.
@IBAction func updateDidTouch(_ sender: Any) {
UIView.animate(withDuration: 0.5, delay: 0, options: UIViewAnimationOptions.curveEaseInOut, animations: {
let newCenterConstraint = NSLayoutConstraint(item: self.myButton, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1.0, constant: …Run Code Online (Sandbox Code Playgroud) 我已经看到了使用Cloud Functions引用实时数据库的增量计数器,但是还没有Firebase Firestore。
我有一个监听新文档的云功能:
exports.addToChainCount = functions.firestore
.document('chains/{name}')
.onCreate((snap, context) => {
// Initialize document
var chainCounterRef = db.collection('counters').doc('chains');
var transaction = db.runTransaction(t => {
return t.get(chainCounterRef).then(doc => {
// Add to the chain count
var newCount = doc.data().count + 1;
t.update(chainCounterRef, { count: newCount });
});
}).then(result => {
console.log('Transaction success!');
}).catch(err => {
console.log('Transaction failure:', err);
});
return true;
});
Run Code Online (Sandbox Code Playgroud)
我正在尝试上述交易,但是firebase deploy在终端中运行时出现此错误:
错误每个then()应该返回一个值或抛出promise / always-return函数预部署错误:命令以非零退出代码终止
这是我对任何node.js的首次尝试,而且我不确定我是否写的正确。
node.js firebase google-cloud-functions google-cloud-firestore
我正在尝试在 SwiftUI 中创建一个操作来向我的数据集Form添加附加内容Child。当我尝试附加时newChild出现错误:
无法对不可变值使用变异成员:“self”是不可变的
struct Child : Identifiable {
var id = UUID()
var birthday: Date
var name: String
}
struct ContentView: View {
var children : [Child] = []
var body: some View {
VStack {
Button(action: {
let newChild = Child(birthday: Date(), name: "Carl")
children.append(newChild)
}) {
Text("Add Child")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
children据我所知,我的数组是可变的,那么为什么我会收到此错误?
我知道 anAlert可以作为 a 的函数呈现Button,但是 anAlert可以在条件中呈现吗?如:
struct ContentView: View {
var body: some View {
Text("Hello World!")
}
}
if isValid {
//present alert
let alert = UIAlertController(title: "My Title", message: "This
is my message.", preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "OK", style:
UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
有了这个我得到
“ContentView”类型的值没有成员“present”
创建视图控制器类名称并将其分配给情节提要中的视图控制器后,更改该名称时,该视图控制器的IBOutlets遇到了问题,并且单击场景时Xcode不会在助手编辑器中自动显示相应的类。
我已经更改了实际文件的名称,文件中的类声明以及情节提要中的视图控制器的类。我还有其他东西吗?
在我的登录中,我UIPageViewController在末尾包含一个 \xe2\x80\x98primer\xe2\x80\x99 屏幕,用于授权通知。用户将点击标有 \xe2\x80\x9cEnable Notifications\xe2\x80\x9d 的按钮,然后将出现通知权限对话框。我该如何实现这个目标?
permissions notifications objective-c apple-push-notifications ios
ios ×7
swift ×6
swiftui ×3
class ×1
firebase ×1
immutability ×1
list ×1
node.js ×1
objective-c ×1
permissions ×1
radio-button ×1
struct ×1
swift3 ×1
uialertview ×1
uibutton ×1
uikit ×1
uilabel ×1
uistackview ×1