我是Swift的新iOS开发人员。我有一个UILocalNotification,我需要添加一个文本字段。例如,某些应用(例如iOS中的“消息”)在发送通知时可以将其向下拖动并回答该通知。快速,如何添加文本字段?
最佳答案
在这里,我的代码在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/