TL;DR:是否可以在不使用APNS
(或替代推送通知服务)的情况下获得重复的随机本地通知?
我正在构建一个Core Data
包含一堆对象的应用程序。(我们将它们称为小部件。)每天的某个时间(假设是中午)我想发送一条通知以查看其中一个小部件。
在didFinishLaunchingWithOptions
我中检查以确保通知已启用并设置委托等,然后调用函数来构建本地通知。所有这一切都运行良好。
var date = DateComponents()
date.hour = 12
date.minute = 00
let content = UNMutableNotificationContent()
content.title = "You should see this widget!"
content.userInfo = ["widgetID": widget.id]
content.body = "Today's Widget:\n\(widget.title!)"
content.sound = UNNotificationSound.default()
let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)
let request = UNNotificationRequest(identifier: notificationIdentifer, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: { (error : Error?) in if let theError = error { print(theError.localizedDescription)}}
Run Code Online (Sandbox Code Playgroud)
我的委托处理程序也正常工作:
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse, …
Run Code Online (Sandbox Code Playgroud) notifications apple-push-notifications swift unusernotificationcenter unnotificationtrigger
For some reason I'm unable to get an image background to aspectFill correctly in XCode Version 12.0, but only on the .systemMedium
widget size. It seems to work perfectly on the small and large sizes.
I've got a pretty simple View:
import SwiftUI
@available(iOS 13.0.0, *)
struct Banana: View {
var body: some View {
VStack(alignment: .leading){
Spacer()
Text("Aardvark Exactlywhat")
.font(.largeTitle)
.bold()
.padding(.bottom, 20)
.padding(.leading, 20)
.padding(.trailing, 20)
.minimumScaleFactor(0.5)
.foregroundColor(.white)
.shadow(
color: Color.black,
radius: 1.0,
x: CGFloat(4),
y: CGFloat(4))
} …
Run Code Online (Sandbox Code Playgroud) 我在视图控制器上有两个按钮.它们的高度和宽度相等,并且在屏幕中心位置很好.问题是在某些情况下,其中一个按钮是隐藏的.当其中一个按钮被隐藏时,我希望另一个按钮居中.
对于我的生活,我一直无法弄清楚如何配置约束来实现这一点.
如果隐藏了另一个按钮,我可以移动可见按钮使其居中,但只能在加载视图后执行此操作,这会使按钮"跳转"并且看起来很傻.
对于我的网络应用程序中的按钮,我几乎只使用带有"btn"类的<a>标签.
问题是,当用户使用<tab>键导航表单字段时,无法确定其中一个"按钮"何时具有焦点,这使他们感到沮丧.
我尝试将其添加到CSS:
a.btn:活性{背景颜色:红;}
但这并不是我想做的事情; 这只是改变了背景颜色,而被点击的按钮.当按钮通过<tab>键接收焦点时,它不会影响按钮的显示方式.
我也尝试过使用:focus而不是:active,但这也不起作用.
有谁知道我可以在我的应用程序中全局更改此方法?