gpt4 book ai didi

ios - swift 中的本地通知 ios

转载 作者:可可西里 更新时间:2023-11-01 01:37:20 26 4
gpt4 key购买 nike

UiApplication.sharedApplication().scheduleLocalNotifications(notification) 给我以下错误 value of type 'uiapplication' has no member 'schedulelocalnotification'

我该如何解决这个问题?

import UIKit

类 SchermataIniziale:UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

let notification = UILocalNotification()

if #available(iOS 8.2, *) {
notification.alertTitle = "Mille Favole"
} else {
// Fallback on earlier versions
}

notification.alertBody = "Ricordati di leggere la favola questa sera"

notification.fireDate = NSDate(timeIntervalSinceNow: 10)

notification.applicationIconBadgeNumber = 1

notification.timeZone = NSTimeZone.defaultTimeZone()

notification.soundName = UILocalNotificationDefaultSoundName

UIApplication.sharedApplication().scheduleLocalNotifications(notification)

//showinitial = false

// Do any additional setup after loading the view.

}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.

}

最佳答案

您需要调用 scheduleLocalNotification 而不是 scheduledLocalNotification

示例:

UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

参见此处:trying to create a local notification but getting error " cannot call value of non function type uilocalnotification " in swift 2

关于ios - swift 中的本地通知 ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35444393/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com