Swift - Get keyboard input as the user is typing

I have an app in swift, where the texfield is located at the bottom of the screen, and when the user tries to type anything, the keyboard covers the textfield, so the user is unable to see what he/she is typing. To solve this, I would like to get the keyboard input from the user, with every stroke/"type" (everytime the user presses a key), and then display it onto a view, which is located just above the keyboard. If this is not possible, or very complex, you are more than welcome to suggest alternative solutions.

Best How To :

You need to register as observer for notifications to see when the keyboard appears and disappears. Then you would move your view up on show, or restore it to original on hide.

My implementation moves the whole view up by keyboard height, but if you want you can just move UITextField up.

You can take a look at this tutorial, or see my implementation in the answer:

Twilio developer evangelist here. Twilio Client uses WebRTC and falls back to Flash in order to make web browsers into phones. Unfortunately Safari on iOS supports neither WebRTC nor Flash so Twilio Client cannot work within any browser on iOS. It is possible to build an iOS application to use...

The official documentation for -setImage:forSegmentAtIndex: says A segment can only have an image or a title; it can’t have both. There is no default image. So, no, there is no way to do what you want using the image and title properties. However, there are a few options to accomplish...

It's crashing because your handler object is getting released and deallocated right after the call to handler.sendMessage(), and then a delegate callback is attempted on that now-deallocated object when you try to send or hit cancel. The object is getting released and deallocated because nothing is holding a strong reference...

In initializeSettingsView() add nibView.setTranslatesAutoresizingMaskIntoConstraints(false). And then in viewDidload add the hight constraint to settingsView constraints.append(NSLayoutConstraint(item: settingsView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 90.0)) And you do not need to set the position of settingsView, since it will be layout at the right position based on...

viewWithTag: is a very fragile way to get a reference to views, and isn't recommended. But what I think is happening is that you need to call viewWithTag: on cell.contentView rather than the cell itself. I'd recommend creating proper IBOutlets to hold your imageview and label....

First of all, you have two main choices: use a imageView with a GIF or use a video for background with AVPlayer or MPMoviePlayerController. You can find a lot of example for both ways, here's a few: use a GIF for cool background video cover iOS In reply to your...

You can get a reference to the view the gesture is added to via its view property. In this case you are adding it to the button so the view property would return you you the button. let button = sender.view as? UIButton ...

If you are thinking about the SWIFT 2.0 error handling to be the same thing as exception you are missunderstanding. This is not exception, this is an error that conforms to a protocol called ErrorType. The purpose of the block is to intercept the error thrown by a throwing function...

Based on the comments on the question, you mentioned that the words will never change. You could potentially create a whole bunch of if/else statements checking every word selected against every word in an array. I have put this down as a more efficient alternative and it should hopefully work....

You'll have to 'remember' which UIViewController calls the object. This can be done for instance with a property. in .h @property (nonatomic) UIViewController *viewController; in your .m file @synthesize viewController; Before calling the method, set the property with anObject.viewController = self; Then, you'll be able to call [viewController finishedPost:self]; inside...

You can do it by using Aspect Ratio property of AutoLayout. You can follow this tutorial. It gives a very nice explanation on how to scale everything up by using fix aspect ratio. http://simblestudios.com/blog/development/percentage-width-in-autolayout.html...

I think your problem is that you are using a calendar with an unset time zone. Your calculation of adding 60*60*24*2 to the current time does not account for the two days when some timezones change to and from daylight savings time. Those days are 23 and 25 hours long....

I would not expect that example to have worked but it does In many cases, Swift can often infer types of variables and expressions. In this case, Swift looks at the value you're returning and can infer the type. If I modify that closure to specify a return type...

What you're trying to do is going to inevitably bump into some serious performance issues in one case or another. Storing all cells (and their data into memory) will quickly use up your application's available memory. On the other hand dequeueing and reloading will produce lags on some devices as...

You don't need to create a new variable for each image, try this: for var i = 1; i < 8; i++ { images.append(UIImage(named: "image\(i)")) } This loop will create an array with 8 images without create the variables image1 to image8. I hope that help you!...

Yes, this is possible using CloudKit. You'll need a CKContainer, and you'll ask it to fetch the user record ID. That record ID is unique for your apps, but is also stable for that user this means the same iCloud account will have the same record ID, regardless of which...

You just need to add this to your code in viewDidLoad. self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero]; EDIT: sorry i was written in objective -c here is in swift. self.tableView.tableFooterView = UIView(frame:CGRectZero) The tableview will display what appear to be extra blank rows to fill out the bounds if there are not...

I think its not possible to use Asset Catalog for video stuff, Its simplify management of images. Apple Documentation Use asset catalogs to simplify management of images that are used by your app as part of its user interface. An asset catalog can include: Image sets: Used for most types...

Because you are using reusable cells when you try to select a cell that is not in the screen anymore the app will crash as the cell is no long exist in memory, try this: if let lastCell = self.diceFaceTable.cellForRowAtIndexPath(lastIndexPath) as! TableViewCell{ lastCell.checkImg.image = UIImage(named: "uncheck") } //update the data...

No, you don't have to use both. Either you go with reloadCell technique or cell updates via beginUpdate and endUpdate. When you are reloading a particular row, internally table view system creates 2 cell and then blends in the new one with. You can remove the beginUpdates and endUpdates and...

appendString: is from NSMutableString, stringByAppendingString: is from NSString. The first one mutates the existing NSMutableString. Adds to the end of the receiver the characters of a given string. The second one returns a new NSString which is a concatenation of the receiver and the parameter. Returns a new string made...

Implement in your ViewController the UITextFieldDelegate protocol, specifically the textField:didEndEditing method. Save your indexPath.row in the textField.tag as you're doing, and set the delegate to the controller, where you can save the value. This is a very simplistic example: class MyViewController : UITableViewController { var texts = [Int:String]() func tableView(tableView:...

You can do it using geometry shaders to create billboarding geometry from each vertex on the GPU. You can then either create the circles as geometry, or create quads and use a circle texture to draw them (I recommend the later). But geometry shaders are not extensively supported yet, even...

That is because you are setting it but you are not saving the value you just set: if signUpError == nil { PFGeoPoint.geoPointForCurrentLocationInBackground { (geoPoint: PFGeoPoint?, error: NSError?) -> Void in if error == nil { PFUser.currentUser()!.setValue(geoPoint, forKey: "location") PFUser.currentUser().saveInBackground() } } ...

Seems to be no error in your code, Check that the arrays in plist has the same naming as in your code might be mistaken something with keys. You can check that by right-click on plist and Open-as then choose source code Like : objectForKey("name") called <key>name</key> objectForKey("image") called <key>image</key>...