Swift-Move view up when keyboard appears with constraints - ios

I am using the following code from "Programming iOS 8". I have a subview with constraints that contains a simple textfield. This view has top and bottom to superview constraints, which I have outlets for. I have an outlet for the subview as well. The goal here is that when the keyboard appears, it pushes this subview up. I get an error on the line "let f = self.fr!.frame" Thread 1: EXC_BAD_INSTRUCTION. Does it have to do with needing to unwrap the optional? Could it be an issue with my constraints? Any help would be much appreciated. Thanks.
import UIKit
class ViewController: UIViewController {
#IBOutlet var topSpace: NSLayoutConstraint!
#IBOutlet var bottomSpace: NSLayoutConstraint!
#IBOutlet var slidingView: UIView!
var fr: UIView?
override func viewDidLoad() {
NSNotificationCenter.defaultCenter().addObserver(
self, selector: "keyboardShow:",
name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(
self, selector: "keyboardHide:",
name: UIKeyboardWillHideNotification, object: nil)
super.viewDidLoad()
}
func textFieldDidBeginEditing(tf: UITextField) {
self.fr = tf // keep track of the first responder
}
func textFieldShouldReturn(tf: UITextField) -> Bool {
tf.resignFirstResponder()
self.fr = nil
return true
}
func keyboardShow(n:NSNotification) {
let d = n.userInfo!
var r = (d[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()
r = self.slidingView.convertRect(r, fromView:nil)
let f = self.fr!.frame
let y : CGFloat =
f.maxY + r.size.height - self.slidingView.bounds.height + 5
if r.origin.y < f.maxY {
self.topSpace.constant = -y
self.bottomSpace.constant = y
self.view.layoutIfNeeded()
}
}
func keyboardHide(n:NSNotification){
self.topSpace.constant = 0
self.bottomSpace.constant = 0
self.view.layoutIfNeeded()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

If I'm not mistaken, the keyboard shows before you start editing, so your self.fr is still nil when your keyboard is shown. Check to see if it's nil. It shouldn't have to do anything with the optional unwrapping. It only fails when you unwrap a null.

Related

Why i am getting gap between view and scrollview while moving keyboard up in swift?

I have arranged views like below
I am getting gap like below Why?
when view is down it looks good, when i tap on textfield then total view goes up and when i scrool tableview i am getting gap between like below.
this is my code:
import UIKit
class ChatViewController: UIViewController, UITextFieldDelegate {
#IBOutlet weak var belowtextFieldHeightConstraint: NSLayoutConstraint!
#IBOutlet weak var catViewBottomConstraint: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboard(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboard(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
#objc func keyboard(notification:Notification) {
guard let keyboardReact = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else {
return
}
if notification.name == UIResponder.keyboardWillShowNotification || notification.name == UIResponder.keyboardWillChangeFrameNotification {
self.view.frame.origin.y = -keyboardReact.height
} else {
self.view.frame.origin.y = 0
}
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
}
Text fields have a property called inputAccessoryView, make sure you are not setting the view anywhere and that it is nil when the keyboard is invoked.
It looks like you have one set up.

Keyboard move up and down

I have a loginView, inside that i have two textFields and a button. I have to move up the view while tapping on textField and move down the view when press the return key.
My problem is that it is working fine for all conditions but while tap on the one textField view is moving up but at same time when we go for next textField view is moving down.
import UIKit
class CheckFontIconView: UIViewController,UITextFieldDelegate {
var activeField: UITextField?
#IBOutlet weak var loginFieldsView: UIView!
#IBOutlet weak var label: UILabel!
#IBOutlet weak var mobileNo: UITextField!
#IBOutlet weak var textFieldPassword: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
mobileNo.delegate = self
textFieldPassword.delegate = self
registerForKeyboardNotifications()
}
#IBAction func btnLoginAction(_ sender: Any) {
}
deinit {
//NotificationCenter.default.removeObserver(self)
self.deregisterFromKeyboardNotifications()
}
func registerForKeyboardNotifications() {
//Adding notifies on keyboard appearing
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWasShown(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillBeHidden(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
}
func deregisterFromKeyboardNotifications() {
//Removing notifies on keyboard appearing
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
}
func keyboardWasShown(notification: NSNotification) {
//Need to calculate keyboard exact size due to Apple suggestions
var info = notification.userInfo!
let keyboardSize = (info[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.size
if self.activeField != nil {
self.loginFieldsView.frame.origin.y -= (keyboardSize?.height)!
}
}
func keyboardWillBeHidden(notification: NSNotification) {
//Once keyboard disappears, restore original positions
var info = notification.userInfo!
let keyboardSize = (info[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.size
self.loginFieldsView.frame.origin.y -= (keyboardSize?.height)!
self.loginFieldsView.endEditing(true)
}
func textFieldDidBeginEditing(_ textField: UITextField) {
self.activeField = textField
}
func textFieldDidEndEditing(_ textField: UITextField) {
self.activeField = nil
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
activeField?.resignFirstResponder()
return true
}
}
Once try with scrollView,I hope it will help you.
Use a scroll view to moving text field up and down.
Making Up
Make a #IBOutlet weak var scroller: UIScrollView!;
Under textFieldDidBeginEditing:textField method
Create a CGPoint with x: 0 and y texfield.frame.origin.y
And then start moving the scroller with setContentOffset:animated function.(Parameter will be your CGPoint and a boolean value true).
Making Down
Under textFieldDidEndEditing:textField set your scroller to CGPoint.zero with same setContentOffset:animated function.
*And your textFieldShouldReturn:textField should be resignFirstResponder or to next textField.
Please let me know if having any problem on this.
Thanks for ask question...
Use TPKeyboard to achieve above functionality then no manage this kind of stuff (Automatically manage by TPKeyboard)...
Update:
I think you have done some mistake in given below code...
func textFieldDidEndEditing(_ textField: UITextField) {
self.activeField = nil
}
You have to DEBUG and identify exact issue..
Happy coding...
I made the simple code for your problem. It is not good but you can refer with that idea for fix your problem.
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
var activeField: UITextField?
#IBOutlet weak var loginFieldsView: UIView!
#IBOutlet weak var label: UILabel!
#IBOutlet weak var mobileNo: UITextField!
#IBOutlet weak var textFieldPassword: UITextField!
var originalHeight:CGFloat!
override func viewDidLoad() {
super.viewDidLoad()
mobileNo.delegate = self
textFieldPassword.delegate = self
originalHeight = self.loginFieldsView.frame.origin.y
registerForKeyboardNotifications()
}
#IBAction func btnLoginAction(_ sender: Any) {
}
deinit {
//NotificationCenter.default.removeObserver(self)
self.deregisterFromKeyboardNotifications()
}
func registerForKeyboardNotifications() {
//Adding notifies on keyboard appearing
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWasShown(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillBeHidden(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
}
func deregisterFromKeyboardNotifications() {
//Removing notifies on keyboard appearing
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
}
func keyboardWasShown(notification: NSNotification) {
//Need to calculate keyboard exact size due to Apple suggestions
var info = notification.userInfo!
let keyboardSize = (info[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.size
if self.activeField != nil {
if self.loginFieldsView.frame.origin.y == originalHeight {
self.loginFieldsView.frame.origin.y -= (keyboardSize?.height)!
}
}
}
func keyboardWillBeHidden(notification: NSNotification) {
//Once keyboard disappears, restore original positions
var info = notification.userInfo!
let keyboardSize = (info[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.size
if originalHeight > self.loginFieldsView.frame.origin.y {
self.loginFieldsView.frame.origin.y += (keyboardSize?.height)!
}
self.loginFieldsView.endEditing(true)
}
func textFieldDidBeginEditing(_ textField: UITextField) {
self.activeField = textField
}
func textFieldDidEndEditing(_ textField: UITextField) {
self.activeField = nil
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
activeField?.resignFirstResponder()
return true
}
}
Just one change hold your view old frame in a variable and assign it again to your view when keyboard disappear.
import UIKit
class CheckFontIconView: UIViewController,UITextFieldDelegate {
var activeField: UITextField?
#IBOutlet weak var loginFieldsView: UIView!
#IBOutlet weak var label: UILabel!
#IBOutlet weak var mobileNo: UITextField!
#IBOutlet weak var textFieldPassword: UITextField!
var previousFrame : CGRect!
override func viewDidLoad() {
super.viewDidLoad()
previousFrame=self.loginFieldsView.frame
mobileNo.delegate = self
textFieldPassword.delegate = self
registerForKeyboardNotifications()
}
func keyboardWasShown(notification: NSNotification) {
//Need to calculate keyboard exact size due to Apple suggestions
var info = notification.userInfo!
let keyboardSize = (info[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.size
if self.activeField != nil {
self.loginFieldsView.frame.origin.y = previousFrame.origin.y-(keyboardSize?.height)!
}
}
func keyboardWillBeHidden(notification: NSNotification) {
//Once keyboard disappears, restore original positions
/*var info = notification.userInfo!
let keyboardSize = (info[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.size*/
self.loginFieldsView.frame = previousFrame
//self.loginFieldsView.endEditing(true)
}
func textFieldDidBeginEditing(_ textField: UITextField) {
self.activeField = textField
}
func textFieldDidEndEditing(_ textField: UITextField) {
self.activeField = nil
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
activeField?.resignFirstResponder()
return true
}
}

inputAccessoryView not showing above keyboard

Problem relates to this.
I'm trying to use a custom view that I made that has two TextField inputs and a button, I made it using IB its xib, I've placed it in my story board and have it set to be at the bottom of my view.
The problem comes in when I want to make ContactInfoView the keyboards accessory view.
class ViewController: UIViewController, UITextViewDelegate {
#IBOutlet var cameraPreview: UIView!
#IBOutlet weak var ContactInfoView: KeyboardAccessoryView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
//cameraPreviewLayer!.frame = cameraPreview.bounds
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillAppear"), name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide"), name: UIKeyboardWillHideNotification, object: nil)
ContactInfoView.NameInput.inputAccessoryView = ContactInfoView
}
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
}
// keyboard stuff
var accessoryView = KeyboardAccessoryView(frame: CGRectZero);
override var inputAccessoryView: KeyboardAccessoryView {
return accessoryView
}
override func becomeFirstResponder() -> Bool {
return true
}
override func canBecomeFirstResponder() -> Bool {
return true
}
func keyboardWillAppear() {
print("Keyboard appeared")
}
func keyboardWillHide() {
print("Keyboard hidden")
}
}
ContactInfoView.NameInput.inputAccessoryView = ContactInfoView isn't placing the view on top of the keyboard.
I fooled out around with the code and it started to crash relating to the link provided, But trying that solution didn't work either.
According to the comment in the UITextView.h file:
#property (nullable, readwrite, strong) UIView *inputView;
#property (nullable, readwrite, strong) UIView *inputAccessoryView;
Presented when object becomes first responder. If set to nil, reverts to following responder chain. If set while first responder, will not take effect until reloadInputViews is called.
You should call reloadInputViews method after setting input.. property.
Yes, This Looks Little Tricky since everything seems fine and same as everyone and the Xcode Auto Suggestion and Completion Tools Helps you to complete the predicted "override" Functions..
Here Is A simple Mistakes that I made While Showing "inputAccessoryView"
I Entered Xcode Suggested Text For Completing "inputAccessoryView" And "inputAccessoryView" for Override Function.
But For Adding "override var inputAccessoryView: UIView?" Func its okay To Select from Xcode Suggestion / Auto Completion
override var inputAccessoryView: UIView? {
get {
return inputContainerView
}
}
For "override var canBecomeFirstResponder : Bool" you should make sure that
you type ": Bool" and not the "() -> Bool", Like I made mistakes couple of time.
So Please If you want You can type yourself or just Copy Below Code Paste in your Class Anywhere and it will work Smoothly.
override var inputAccessoryView: UIView? {
get {
let inputContainerView = UIView()
inputContainerView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: 50)
inputContainerView.backgroundColor = UIColor.gray
let textfield = UITextField()
textfield.text = "asasfdfs df sdf sdf ds f"
textfield.frame = CGRect(x: 0, y: 0, width: inputContainerView.frame.size.width, height: 50)
inputContainerView.addSubview(textfield)
// You can add Any Other Objects Like UIButton, Image, Label //you want And Constraints too.
return inputContainerView
}
}
override var canBecomeFirstResponder : Bool {
return true
}
In the code above, you are assigning the property InputAccessoryView not the property inputAccessoryView. Case is important.
Assuming everything else is setup correctly, this should get it to work, but there is something I don't understand. Why is your text field/text view a property of your input accessory view? If NameInput is a subview of ContactInfoView, then setting ContactInfoView.NameInput.inputAccessoryView will not work.

IOS swift when keyboard apears it hiddes the top 2 TextField

This is my whole code when keyboard appears it hides the top 1 textfield and one is half visible. It works but when it hiddes the top fields it looks to wired.
I found this code on net but i can't able to fix it.
class ViewController2: UIViewController, ENSideMenuDelegate, UITextFieldDelegate {
#IBOutlet weak var text1: UITextField!
#IBOutlet weak var text2: UITextField!
#IBOutlet weak var text3: UITextField!
#IBOutlet weak var text4: UITextField!
#IBOutlet weak var scrollview: UIScrollView!
var activeTextField: UITextField!
#IBOutlet weak var container_view: UIView!
override func viewDidLoad() {
super.viewDidLoad()
//Move next line to viewWillAppear functon if you store your view controllers
self.sideMenuController()?.sideMenu?.delegate = self
// Do any additional setup after loading the view.
self.text1.delegate = self
self.text2.delegate = self
self.text3.delegate = self
self.text4.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - ENSideMenu Delegate
func sideMenuWillOpen() {
println("sideMenuWillOpen")
}
func sideMenuWillClose() {
println("sideMenuWillClose")
}
func sideMenuDidClose() {
println("sideMenuDidClose")
}
func sideMenuDidOpen() {
println("sideMenuDidOpen")
}
/*
func sideMenuShouldOpenSideMenu() -> Bool {
println("sideMenuShouldOpenSideMenu")
return false
}
*/
// MARK: - Keyboard
// Call this method somewhere in your view controller setup code.
func registerForKeyboardNotifications() {
let notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.addObserver(self,
selector: "keyboardWillBeShown:",
name: UIKeyboardWillShowNotification,
object: nil)
notificationCenter.addObserver(self,
selector: "keyboardWillBeHidden:",
name: UIKeyboardWillHideNotification,
object: nil)
}
func unregisterFromKeyboardNotifications () {
let center: NSNotificationCenter = NSNotificationCenter.defaultCenter()
center.removeObserver(self, name: UIKeyboardDidShowNotification, object: nil)
center.removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
}
private func stopObservingKeyboardEvents() {
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
}
// Called when the UIKeyboardDidShowNotification is sent.
func keyboardWillBeShown(sender: NSNotification) {
let info: NSDictionary = sender.userInfo!
let value: NSValue = info.valueForKey(UIKeyboardFrameBeginUserInfoKey) as! NSValue
let keyboardSize: CGSize = value.CGRectValue().size
let contentInsets: UIEdgeInsets = UIEdgeInsetsMake(0.0, 0.0, keyboardSize.height, 0.0)
scrollview.contentInset = contentInsets
scrollview.scrollIndicatorInsets = contentInsets
// If active text field is hidden by keyboard, scroll it so it's visible
// Your app might not need or want this behavior.
var aRect: CGRect = self.view.frame
aRect.size.height -= keyboardSize.height + 80
let activeTextFieldRect: CGRect? = activeTextField?.frame
let activeTextFieldOrigin: CGPoint? = activeTextFieldRect?.origin
if (!CGRectContainsPoint(aRect, activeTextFieldOrigin!)) {
scrollview.scrollRectToVisible(activeTextFieldRect!, animated:true)
}
}
// Called when the UIKeyboardWillHideNotification is sent
func keyboardWillBeHidden(sender: NSNotification) {
let contentInsets: UIEdgeInsets = UIEdgeInsetsZero
scrollview.contentInset = contentInsets
scrollview.scrollIndicatorInsets = contentInsets
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.registerForKeyboardNotifications()
}
override func viewDidDisappear(animated: Bool) {
super.viewWillDisappear(animated)
NSNotificationCenter.defaultCenter().removeObserver(self)
}
// MARK: - Text Field
func textFieldDidBeginEditing(textField: UITextField) {
self.activeTextField = textField
}
func textFieldDidEndEditing(textField: UITextField) {
self.activeTextField = nil
}
}
Instead of doing this
var aRect: CGRect = self.view.frame
aRect.size.height -= keyboardSize.height + 80
do this
self.view.frame.y -= keyboardSize.height + 80
(not sure what the 80 is, but I'm keeping it there in case it is accounting for something on your app.)
the .height property will stretch your frame while the .y property will move it.

How do I adjust the size of a UITextView? Swift

I have a problem with my app, look at this pic
Now I'm typing on textView , I want a way to resize the textview or move it to top or scrolling to the last where I'm typing please help
I saw many answers here but all not working with me , and this is the code when i tried one of the answers
import UIKit
class AddEditClassNoteViewController: UIViewController {
#IBOutlet var keyboardHeightLayoutConstraint: NSLayoutConstraint?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
#IBOutlet weak var noteTextBox: UITextView!
override func touchesBegan(touches: NSSet, withEvent event: UIEvent)
{
self.noteTextBox.resignFirstResponder()
}
func textFieldDidBeginEditing(textField: UITextField) {
animateViewMoving(true,moveValue: 100)
}
func textFieldDidEndEditing(textField: UITextField) {
animateViewMoving(false,moveValue: 100)
}
func animateViewMoving (up:Bool, moveValue :CGFloat){
var movementDuration:NSTimeInterval = 0.3
var movement:CGFloat = ( up ? -moveValue : moveValue)
UIView.beginAnimations( "animateView", context: nil)
UIView.setAnimationBeginsFromCurrentState(true)
UIView.setAnimationDuration(movementDuration )
self.view.frame = CGRectOffset(self.view.frame, 0, movement)
UIView.commitAnimations()
}
}
Im using Swift IOS 8
It seems like you're asking for several things, (all of which, I'm guessing, already have answers on Stack Overflow) but I'll do my best to give you a few examples.
First, what you have so far seems to hide the keyboard when you tap on the view. That may be partially defeating your purpose.
Second, if you're trying to scroll to the top of the your noteTextBox, try using:
noteTextBox.setContentOffset(CGPointMake(0, 0), animated: true) [Use animted: true if you want a scrolling animation. You may not, I don't know]
Third, check out this question for resizing the UITextView: Click Here
Fourth, check out this question for returning to a "remembered" position on your UIView: Click Here
Good luck,
Kyle
for any one need the answer with Swift language , The answer is as following simple change only .
import UIKit
class AddEditClassNoteViewController: UIViewController {
var keyboardShowing = false
#IBOutlet weak var noteTextBox: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardHide:", name: UIKeyboardWillHideNotification, object: nil)
// Do any additional setup after loading the view.
}
override func shouldAutorotate() -> Bool {
return !self.keyboardShowing
}
// much simpler than in iOS 7; a lot of the touchy bugs are gone in iOS 8
// as long as you play your part (adjust content offset),
// iOS 8 will play its part (scroll cursor to visible)
// and we don't have to animate
func keyboardShow(n:NSNotification) {
self.keyboardShowing = true
let d = n.userInfo!
var r = (d[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()
r = self.noteTextBox.convertRect(r, fromView:nil)
self.noteTextBox.contentInset.bottom = r.size.height
self.noteTextBox.scrollIndicatorInsets.bottom = r.size.height
}
func keyboardHide(n:NSNotification) {
self.keyboardShowing = false
self.noteTextBox.contentInset = UIEdgeInsetsZero
self.noteTextBox.scrollIndicatorInsets = UIEdgeInsetsZero
}
func doDone(sender:AnyObject) {
self.view.endEditing(false)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent)
{
self.noteTextBox.resignFirstResponder()
}
}
Thanks for all who was trying to helping me .

Resources