gpt4 book ai didi

ios - 在 Swift 中向 UILocalNotification 添加文本字段

转载 作者:行者123 更新时间:2023-11-29 01:55:44 26 4
gpt4 key购买 nike

我是 iOS 开发新手,使用 swift。我有一个 UILocalNotification,我需要向其中添加一个文本字段。例如,在发送通知时,某些应用程序(如 iOS 中的消息)可以将该通知向下拖动并回复该通知。在 swift 中,我如何添加文本字段?

最佳答案

在我的代码中,我在 UITextField 中添加了 UIlocalNotifications(fireDate)。

 override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

var localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "Testing notifications on iOS8"
localNotification.alertBody = "Date and Time"
localNotification.fireDate = NSDate(timeIntervalSinceNow: 30)
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)


var myTextField: UITextField = UITextField(frame: CGRect(x: 5, y: 100, width:310.00, height: 40.00));
myTextField.layer.borderWidth = 1
self.view.addSubview(myTextField)

// convert to string
var date = NSString(format:"%@ ", localNotification.fireDate!) as String

// add to textfield
myTextField.text = date
}

我希望你正在寻找这个。

谢谢

关于ios - 在 Swift 中向 UILocalNotification 添加文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30886159/

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