我想将一些内容放在 Bootstrap 4 卡中,并在上面有一个拉伸链接。我还想在这张卡片中包含一个按钮,它的 URL 与拉伸链接不同。
Bootstrap 的文档说:
不建议使用拉伸链接使用多个链接和点击目标。但是,如果需要,某些位置和 z-index 样式可以提供帮助。
但我无法让它工作。
我尝试过将按钮的 z-index 设置为 5000 之类的方法,但它仍然无法点击。
<div class="card">
<div class="card-body">
<div class="row">
<div class="col align-self-center">
<h5 class="card-title">This is a card</h5>
<h6 class="card-subtitle mb-2 text-muted">It has a button in it</h6>
<p class="card-text">How do I make the button rise up above the stretched link?</p>
</div>
<div class="col-auto align-self-center">
<a class="btn btn-primary" href="https://www.stackoverflow.com" role="button">Button Link</a>
</div>
<a href="https://www.duckduckgo.com" class="stretched-link"></a>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想让它可以点击按钮,而不会被拉伸的链接覆盖。
有小费吗?
我正在尝试重新创建与股票 iOS 日历应用程序中的事件列表相匹配的视图。我有以下代码生成一个事件列表,每个事件按日期分成自己的部分:
var body: some View {
NavigationView {
List {
ForEach(userData.occurrences) { occurrence in
Section(header: Text("\(occurrence.start, formatter: Self.dateFormatter)")) {
NavigationLink(
destination: OccurrenceDetail(occurrence: occurrence)
.environmentObject(self.userData)
) {
OccurrenceRow(occurrence: occurrence)
}
}
}
}
.navigationBarTitle(Text("Events"))
}.onAppear(perform: populate)
}
Run Code Online (Sandbox Code Playgroud)
这段代码的问题在于,如果同一日期有两个事件,它们会被分成具有相同标题的不同部分,而不是被组合到同一部分中。
作为一个 Swift 新手,我的直觉是做这样的事情:
ForEach(userData.occurrences) { occurrence in
if occurrence.start != self.date {
Section(header: Text("\(occurrence.start, formatter: Self.dateFormatter)")) {
NavigationLink(
destination: OccurrenceDetail(occurrence: occurrence)
.environmentObject(self.userData)
) {
OccurrenceRow(occurrence: occurrence)
}
}
} else {
NavigationLink(
destination: OccurrenceDetail(occurrence: occurrence)
.environmentObject(self.userData)
) {
OccurrenceRow(occurrence: occurrence)
} …Run Code Online (Sandbox Code Playgroud) 我正在从 Django 应用程序(使用django-push-notifications)向 iOS 应用程序发送推送通知。该应用程序面向 iOS 13,我在运行 iOS 13.3.1 的 iPhone 7 上运行它。我正在 Xcode 11.3.1 中调试
我正在尝试两种不同的方法来从 Django 端发送通知:
方法一:
devices.send_message(message={"title" : title, "body" : message}, thread_id="events", extra={"foo": "bar"})
Run Code Online (Sandbox Code Playgroud)
方法二:
devices.send_message("[will be overwritten]", extra={
"aps": {
"alert": {
"title": "Bold text in the notification",
"body": "Second line in the notification"
},
"sound": "default",
},
"foo": "bar"
})
Run Code Online (Sandbox Code Playgroud)
据我所知,这两种方法都应该产生一个类似于方法 2 的负载。
我正在通过执行以下操作进行调试:
无论我做什么,launchOptions 始终为零。我试过设置断点来检查变量。如果 launchOptions 不为零,我尝试使用 os_log 登录到控制台,并且我尝试触发警报(遵循此问题的建议)以排除 Xcode 调试器干扰。它始终为零。 …
试图制作一个类似于 Apple 日历应用程序中的“创建事件”模式的模式。我在父 NavigationView 中使用以下代码成功显示了我的模式:
.navigationBarItems(trailing:
Button(action: {
self.isModal = true
}) {
Image(systemName: "plus").sheet(isPresented: $isModal, content: {
EventCreate(showModal: self.$isModal)
})
}
)
Run Code Online (Sandbox Code Playgroud)
模态显示成功,但我无法在模态中显示 NavigationBar,如下所示:
struct EventCreate: View {
@Binding var showModal: Bool
@State var event = Event(id: 0, title: "", description: "", location: "", start: Date(), end: Date(), cancelled: false, public_occurrence: false, created: "", last_updated: "", guests: -1)
var body: some View {
NavigationView {
Form{
Section {
TextField("Title", text: $event.title)
TextField("Location", text: $event.location)
}
Section {
DatePicker(selection: $event.start, …Run Code Online (Sandbox Code Playgroud) 我可以使用以下选择器选择事件应多久发生一次:
struct RecurrenceSelector: View {
@State var interval = 1
var body: some View {
NavigationView {
Form {
Section {
Picker("Every", selection: $interval) {
Text("1 week").tag(1)
ForEach(2 ..< 1000) { weeks in
Text("\(weeks) weeks")
.tag(weeks)
}
}.pickerStyle(WheelPickerStyle())
}
}
}
.onDisappear(perform: updateRruleString)
}
private func updateRruleString() {
print("INTERVAL: \(self.interval)")
}
}
Run Code Online (Sandbox Code Playgroud)
关闭视图时,如果将“选择器”设置为5周,则将打印INTERVAL:3。如果将其设置为20周,则将打印INTERVAL:18。
我不知道为什么值要减去2。