我是swift的新iOS开发人员。我有一个UILocalNotification我需要添加一个文本字段。例如,在发送通知时,某些应用程序(例如iOS中的消息)可以将该通知拖至关闭并回答该通知。在swift中,我如何添加文本字段?
答案 0 :(得分:1)
这里我的代码我在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
}
我希望你能找到这个。
谢谢