Cursor issue while creating Custom keyboard with UIView - ios

My requirement was to make a application specific keyboard i.e with a different theme and different key contents as compared to the default keyboard. But the way Apple states to implement keyboard requires user effort to add it through Settings->General->Keyboard which I don't want.
So, for that I tried to implement it using a UIView and making it the inputView for UITextView and it is working perfectly fine except for one issue. I added a functionality to add a linebreak in the textView. For that the code I used is
textView.text = "\(textView.text)\n"
Now, whenever I add a linebreak through keyboard, line is changed, but a new cursor appears to blink above the old cursor. I don't know how to get rid of that.
To explain the problem in a better way, here's a GIF image of the issue.
Please help.

Related

Text Field doesn't active for Static Cell in Table View Controller?

I have Single View App for IOS Xcode 6.4. Example Add Player screen, I tried it by myself, but Text Field doesn't active to click and typing at my application simulator (UITableViewController Static Cell) I have compared my project with example final project, everything looks good similar. How to fix this problem?
First you try with cmd+k that will open the simulator's keyboard. If that is not working then try with cmd+shit+k that may hide your keyboard but you can able to type on the text filed. If that also not work then you may accidentally off the user interaction for text field. Or may be some other view covering your text field which is transparent, so you are not able to see it. I hope that will save your problem, otherwise please provide your code sample.
There is a bug in the segue transition. Set the transition to None and it should work. I had the problem with a Curl transition.

iOS Add Image to TextField

I am experimenting a little bit witch apps programming.
How I can add a UIImage to a UITextField"?
Like Whats App or the most other Chat Apps.
I have search some time but doesn't find a solution, also i have tried to search in side of XCode with the auto complete but I have not found a function. So I hope you can help me.
The easiest way to add an image to a text field is to have a UIView that contains both UITextField and a UIImageView as subviews.
Next up, you can have a UIButton with both an image and text, and just set userInteractionEnabled to "NO" and it'll behave like a text view with an image next to it.
Now to get more complicated, if you want a chat-like text field that allows text (that you can type into) and images next to each other, you need to start thinking about custom subclasses. Other people have asked and have gotten answers for this same approach.

iOS custom keyboard on iPad

I'm building an iPad app witch will use a numeric keyboard. The numeric keyboard for the iPad is really huge, all i need is something smaller, something like the decimal keyboard for the iphone.
If i use the default one, half the screen gets covered with keys i dont need. I know i can move the textfields out of the way but it is such a waste of screen space.
So i tried building a custom UIView with no button for start and setting the textfield.inputview to my custom UIView.
The only thing i got is that my custom view is displayed like/in place of/the stock keyboard and the only thing i can change is the height of the custom view.
How could i build a sort of custom keyboard that apple will accept and works with the textfields.
Thank you.
I found what i was looking for. The answer is UIPopover. I managed to build a custom keypad inside a uipopover.
Here's a good tutorial for the uipopover:
http://www.appcoda.com/uiactionsheet-uipopovercontroller-tutorial/
And here's some more info on what you have to do to make it work:
http://iphone-bitcode.blogspot.fr/2011/12/custom-number-pad-on-ipad.html

IOS 8:custom Keyboard with undo and redo button

I have developed an IOS 8 custom keyboard. I want to give it "undo" and "redo" functionality, like the default system keyboard. I have tried it in different ways but was unable to find a good solution.
We can interact with a Text Input Object textDocumentProxy with the methods
insertText
deleteBackward
documentContextAfterInput
ocumentContextBeforeInput
But I was unable to find any way of implementing "undo" and "redo" functionality.
I think we can NOT implement these function (undo,redo)
According to https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html
Because a custom keyboard can draw only within the primary view of its
UIInputViewController object, it cannot select text. Text selection is
under the control of the app that is using the keyboard. If that app
provides an editing menu interface (such as for Cut, Copy, and Paste),
the keyboard has no access to it. A custom keyboard cannot offer
inline autocorrection controls near the insertion point.
I think there are many case that content of textfield changed and you can not know when it changed, how it changed. If we can not know, we can not know to undo to where too. I think so.
I'm developing Custom keyboard extension like you and I have many problems. (eg: how can we know the current cursor to get current text selection...)
My question: Current text selection in CustomKeyBoardExtension (hope somebody know)

How to write multiple lines in a label

I have a XIB file of type View XIB. In it I have a View controller, and in the View controller I have a label.
I have long text that I want to break, but it doesn't - it gets truncated.
I tried this solution - I did it in the attribute window - but it doesn't help.
You could use a TextView and disable the Editable and User Interaction Enabled options in IB.
use this
myLabel.lineBreakMode = UILineBreakModeWordWrap;
if you are worried about backwards compatibility use this because the comand i mentioned before was introduced in iOS 6.0
myLabel.numberOfLines = 0;
I have been running into a similar problem. I started out with a label, but wanted multi-lines and a UITextView worked great for this, at first. Because I am using a third party library (MBProgressHUD) to handle stuff like progress messages and what not, I had thread problems when trying to update a UITextView and show the progress message at the same time.
So I went back to UILabel which actually didn't have thread problems. I found a property to allow a specific number of lines of my choosing, and had to create the label big enough to display those lines. The downfall to this approach is that I don't get the context menus like Copy, Paste, etc. but more importantly I'm not running into thread problems. I can always embed this into a UIScrollView in the future if I so choose.
You could check out my category for UILabel on GitHub. https://gist.github.com/1005520
This lets you resize the height of the label to accommodate the content.
From the Attiribute inspector, choose LineBreaks->Word Wrap option when you have selected the lablel. Also increase the number of lines Label->Lines.
Try Following steps to solve issue :
Drag out a UITextView.
Double-click it to edit text, place cursor where you want the
paragraph break.
Option-Enter a couple of times to create a blank line & paragraph.

Resources