Mahdi Appleseed
Mahdi Appleseed

Reputation: 79

Adding Text Field To UILocalNotification In Swift

i'm a new iOS developer with swift. i have a UILocalNotification And i need to add a text field to that . for example some apps like Messages in iOS when sending notification you can drag that notification to down and answer to that Notification. in swift, how can i add a text field ?

Upvotes: 0

Views: 746

Answers (1)

Shanmugasundharam
Shanmugasundharam

Reputation: 2092

Here my code i added UIlocalNotifications(fireDate) in UITextField.

 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
}

I hope you looking for this one.

Thanks

Upvotes: 1

Related Questions